2011-04-19 122 views
5

我試圖在詹金斯運行msbuild。 當它到達UNITEST項目錯誤occures:msbuild - UnitTestFramework參考無法解析

Project "C:\Program Files (x86)\Jenkins\jobs\***\workspace\***.sln" (1) is building "C:\Program Files (x86)\Jenkins\jobs\***\workspace\***.unitTests\***.unitTests.csproj" (4) on node 0 (default targets). 
Project file contains ToolsVersion="4.0", which is not supported by this version of MSBuild. Treating the project as if it had ToolsVersion="3.5". 
ResolveAssemblyReferences: 
    Primary reference "Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL". 
     Could not find dependent files. Could not load file or assembly 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. 
C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets : warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. 
      For SearchPath "{Registry:Software\Microsoft\.NetFramework,v4.0,AssemblyFoldersEx}". 
      Considered "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VSTSDB\Microsoft.VisualStudio.QualityTools.UnitTestFramework.exe", but it didn't exist. 
      Considered "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VSTSDB\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll", but it didn't exist. 
      Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\2.0\Runtime\v4.0\Microsoft.VisualStudio.QualityTools.UnitTestFramework.exe", but it didn't exist. 
      Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\2.0\Runtime\v4.0\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll", but it didn't exist. 
      Considered "C:\Program Files (x86)\MySQL\MySQL Connector Net 6.3.6\Assemblies\v2.0\Microsoft.VisualStudio.QualityTools.UnitTestFramework.exe", but it didn't exist. 
      Considered "C:\Program Files (x86)\MySQL\MySQL Connector Net 6.3.6\Assemblies\v2.0\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll", but it didn't exist. 
      Considered "C:\Program Files (x86)\MySQL\MySQL Connector Net 6.3.6\Assemblies\v4.0\Microsoft.VisualStudio.QualityTools.UnitTestFramework.exe", but it didn't exist. 
      Considered "C:\Program Files (x86)\MySQL\MySQL Connector Net 6.3.6\Assemblies\v4.0\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll", but it didn't exist. 
      Considered "C:\Program Files (x86)\Microsoft.NET\Primary Interop Assemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.exe", but it didn't exist. 
      Considered "C:\Program Files (x86)\Microsoft.NET\Primary Interop Assemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll", but it didn't exist. 
      Considered "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.exe", but it didn't exist. 
CalculatorServiceTest.cs(1,17): error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) 
CalculatorServiceTest.cs(11,10): error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?) 
CalculatorServiceTest.cs(11,10): error CS0246: The type or namespace name 'TestMethodAttribute' could not be found (are you missing a using directive or an assembly reference?) 
CalculatorServiceTest.cs(24,10): error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?) 
CalculatorServiceTest.cs(24,10): error CS0246: The type or namespace name 'TestMethodAttribute' could not be found (are you missing a using directive or an assembly reference?) 
CalculatorServiceTest.cs(37,10): error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?) 
CalculatorServiceTest.cs(37,10): error CS0246: The type or namespace name 'TestMethodAttribute' could not be found (are you missing a using directive or an assembly reference?) 
CalculatorServiceTest.cs(6,6): error CS0246: The type or namespace name 'TestClass' could not be found (are you missing a using directive or an assembly reference?) 
CalculatorServiceTest.cs(6,6): error CS0246: The type or namespace name 'TestClassAttribute' could not be found (are you missing a using directive or an assembly reference?) 
Done Building Project "C:\Program Files (x86)\Jenkins\jobs\***\workspace\***.unitTests\***.unitTests.csproj" (default targets) -- FAILED. 
Done Building Project "C:\Program Files (x86)\Jenkins\jobs\***\workspace\***.sln" (default targets) -- FAILED. 

Build FAILED. 

任何建議,問題可能是什麼?從命令運行MS構建工作的解決方案,沒有任何額外的參數該項目編譯在VS bevor。乾淨的解決方案後,會出現相同的錯誤。必須是一些參數或參考問題;第二行會談v4和v3.5問題;但我無法弄清楚如何解決這個問題。

映入眼簾,從在cmd默認的Windows使用

+0

我無法理解何時發生錯誤,何時從IDE或從命令行構建?什麼是「bevor」以及你試圖從哪個命令shell構建?看起來像你有一個3.5命令shell試圖用4.0程序集構建。 – 2011-04-20 04:22:22

回答

2

錯誤信息直接顯示您使用的MSBuild

該組件是建立在不正確的版本由運行時比當前加載的運行庫更新,無法加載。

嘗試重建用的MSBuild 4.0

C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe *.sln /t:rebuild 

或/與從VS2010命令行。

0

林建設:

C:\ MSBuild.exe *的.sln

的解決方案,項目全部3.5;只有單元測試項目是4.0(因爲你不能改變這一點)

我剛纔提到,建立它的方式工作,當我用VS創建它,並且不刪除(乾淨的解決方案)二進制文件。沒關係。

如何從cmd使用msbuild構建包含unittests的* .sln?

2

我有一個類似的問題,這似乎是由在系統帳戶下運行Jenkins作爲服務引起的。不知何故,cmd.exe並沒有引用所有必要的環境變量來找到我的NUnit程序集。

如果您將Jenkins作爲服務運行,請嘗試將其設置爲以您的用戶帳戶運行並查看是否有幫助。

+0

您可以通過下載PSTools(http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx)並運行PsTools/PsExec.exe -i -s cmd.exe來檢查此問題,它允許您運行命令提示爲本地系統用戶。這樣就可以讓你模仿jenkins並運行命令行工具,就好像你是那個用戶一樣。 (通過http://computercamp.cdwilson.us/jenkins-git-clone-via-ssh-on-windows-7-x64發現) – Jane 2012-09-25 14:51:56

相關問題