最後我找到了解決這個問題的方法。我不知道爲什麼,但你必須編寫你自己的程序集解析器。我發現這裏的解決方案:
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