最后我找到了解决这个问题的方法。我不知道为什么,但你必须编写你自己的程序集解析器。我发现这里的解决方案:
http://blog.csdn.net/marryshi/article/details/8100194
然而,我不得不更新为VS2012的注册表路径:
static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
AssemblyName assemblyName = new AssemblyName(args.Name);
if (assemblyName.Name.StartsWith("Microsoft.VisualStudio.TestTools.UITest", StringComparison.Ordinal))
{
string path = string.Empty;
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\VisualStudio\11.0"))
{
if (key != null)
{
path = key.GetValue("InstallDir") as string;
}
}
if (!string.IsNullOrWhiteSpace(path))
{
string assemblyPath = Path.Combine(path, "PublicAssemblies",
string.Format(CultureInfo.InvariantCulture, "{0}.dll", assemblyName.Name));
if (!File.Exists(assemblyPath))
{
assemblyPath = Path.Combine(path, "PrivateAssemblies",
string.Format(CultureInfo.InvariantCulture, "{0}.dll", assemblyName.Name));
if (!File.Exists(assemblyPath))
{
string commonFiles = Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFilesX86);
if (string.IsNullOrWhiteSpace(commonFiles))
{
commonFiles = Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles);
}
assemblyPath = Path.Combine(commonFiles, "Microsoft Shared", "VSTT", "10.0",
string.Format(CultureInfo.InvariantCulture, "{0}.dll", assemblyName.Name));
}
}
if (File.Exists(assemblyPath))
{
return Assembly.LoadFrom(assemblyPath);
}
}
}
return null;
}
我运行功能之前,注册表解析:
[BeforeFeature]
public static void Initialize()
{
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
}
不这发生在您的开发机器上,还是仅在构建服务器上? – AlSki
它发生在开发机器上... – Sourabh