MSBuild找不到引用 [英] MSBuild cannot find a reference

查看:279
本文介绍了MSBuild找不到引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正试图找出为什么MSBuild不能编译我们的单元测试DLL。



这是我从TeamCity收到的输出,当生成失败时:

  [10:38:55]:NAnt输出:
[10:38:55]:[exec]
[ 10:38:55]:[exec]
[10:38:55]:[exec]C:\Robinson\trunk\Projects\Robinson\Robinson.sln(默认目标) (1) - >
[10:38:55]:[exec]C:\Robinson\trunk\Projects\Robinson\TenForceExecutionTests\TenForceExecutionTests.csproj(默认目标)(19) - >
[10:38:55]:[exec](CoreCompile target) - >
[10:38:55]:[exec] Modules \SecurityModuleTests.cs(10,30):错误CS0234:类型或命名空间名称'Modules'不存在于命名空间'TenForce.Execution.Web '(你缺少一个程序集引用吗?)[C:\Robinson\trunk\Projects\Robinson\TenForceExecutionTests\TenForceExecutionTests.csproj]
[10:38:55]:[exec] Modules \SecurityModuleTests.cs(197,39):错误CS0246:无法找到类型或命名空间名称SecurityModule(是否缺少using指令或程序集引用?)[C:\Robinson\trunk\项目\Robinson\TenForceExecutionTests\TenForceExecutionTests.csproj]
[10:38:55]:[exec] TranslateTests.cs(10,30):错误CS0234:类型或命名空间名称'Utils'不存在于命名空间'TenForce.Execution.Web'(是否缺少程序集引用?)[C:\Robinson\trunk\Projects\Robinson\TenForceExecutionTests\TenForceExecutionTests.csproj]
[10 :38:55]:[exec] IPETests.cs(8,30):错误CS0234:命名空间'TenForce.Execution.Web'中不存在类型或命名空间名称'Ajax'(是否缺少程序集引用? )[c:\Robinson\trunk\Projects\Robinson\TenForceExecutionTests\TenForceExecutionTests.csproj]
[10:38:55]:[exec] Pages\BasePageTest.cs(6,30 ):错误CS0234:命名空间TenForce.Execution.Web中不存在类型或命名空间名称Utils(是否缺少程序集引用?)[C:\Robinson\trunk\Projects\Robinson \TenForceExecutionTests\TenForceExecutionTests.csproj]
[10:38:55]:[exec] Pages\BasePageTest.cs(7,30):error CS0234:类型或命名空间名称'Pages'不存在在命名空间'TenForce.Execution.Web'(你缺少一个程序集引用吗?)[C:\Robinson\trunk\Projects\Robinson\TenForceExecutionTests\TenForceExecutionTests.csproj]
[10: 38:55]:[exec] ServiceAsmxTests.cs(9,30):error CS0234:命名空间'TenForce.Execution.Web'中不存在类型或命名空间名称'Ajax'(是否缺少程序集引用? [c:\Robinson\trunk\Projects\Robinson\TenForceExecutionTests\TenForceExecutionTests.csproj]
[10:38:55]:[exec] ServiceAsmxTests.cs(10,30):error CS0234 :类型或命名空间名称'Utils'不存在于命名空间'TenForce.Execution.Web'中(是否缺少程序集引用?)[C:\Robinson\trunk\Projects\Robinson\TenForceExecutionTests\\ \\ TenForceExecutionTests.csproj]
[10:38:55]:[exec] Pages\BasePageTest.cs(16,17):错误CS0246:无法找到类型或命名空间名称basepage缺少一个使用指令或程序集引用?)[C:\Robinson \trunk\Projects\Robinson\TenForceExecutionTests\TenForceExecutionTests.csproj]
[10:38:55]:[exec] ServiceAsmxTests .cs(22,17):error CS0246:找不到类型或命名空间名称Service(是否缺少using指令或程序集引用?)[C:\Robinson\trunk\Projects\ Robinson \TenForceExecutionTests \TenForceExecutionTests.csproj]
[10:38:55]:[exec]
[10:38:55]:[exec] 2075警告
[ 10:38:55]:[exec] 10错误
[10:38:55]:[exec]
[10:38:55]:[exec]时间经过00:01 :40.06

项目 TenForceExecutionTests 简单的DLL包含几个单元测试的MBunit框架。此项目引用了 TenForceExecution 这是一个Web应用程序项目,另一个引用 TenForce.Execution.Test ,这是另一个DLL包含两个项目的逻辑。



当我们在开发机器上编译所有东西时,它没有问题,编译无错误。但在构建代理,但这似乎失败...



INFO




  • 目标框架:.NET4

  • 操作系统:Windows XP 32位




EDIT



做了一个干净的检查,Visual Studio能够构建整个解决方案,但是msbuild不能。



编辑2



检查依赖关系:






> EDIT 3
当我删除对webApplication项目的引用,并将其替换为该项目的编译DLL的引用时,错误消失,项目编译与MSBuild精细。



编辑4
我从msbuild通过LOG运行整个构建,查看编译出现问题的项目的具体任务:

 任务Csc
c:\Windows \\ \\ microsoft.NET \Framework\v4.0.30319\Csc.exe / noconfig / nowarn:1701,1702 / nostdlib + / errorreport:prompt / warn:4 / define:DEBUG; TRACE / reference:D:\Users\\ \\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\ThirdPartyComponents\ASP.dll /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\ RobinsonSource\Projects\Robinson\BUL\bin\Debug\BUL.dll /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson \BULTest\bin\Debug\BULTest.dll /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\DAL\bin\\ \\Debug\DAL.dll /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\Framework\bin\Debug\Framework.dll /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\ThirdPartyComponents\Gallio.dll /reference:D:\Users\arne.de .herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\ThirdPartyComponents\Iesi.Collections.dll /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\\ \\ Projects\Robinson\LanguageResource\bin\Debug\LanguageResource.dll /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\ ThirdPartyComponents \log4net.dll /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\ThirdPartyComponents\MbUnit.dll / reference:C:\\ \\ Program Files(x86)\ Reference Assemblies \ Microsoft \\ Documents\RobinsonSource\Projects\Robinson\ThirdPartyComponents\NHibernate.dll /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\PresentationBridge \bin\Debug\PresentationBridge.dll /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\PresentationBridgeTest\bin\Debug\\ \\ PresentationBridgeTest.dll / reference:C:\Program Files(x86)\Reference Assemblies \Microsoft\Framework\.NETFramework\v4.0\System.Configuration.dll/ reference:C: \Program Files(x86)\Reference Assemblies \Microsoft\Framework\.NETFramework\v4.0\System.Core.dll/ reference:C:\Program Files(x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.dll/reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects \Robinson\ThirdPartyComponents\System.Data.SQLite.DLL / reference:C:\Program Files(x86)\Reference Assemblies \Microsoft\Framework\.NETFramework\v4.0\System .dll/ reference:C:\Program Files(x86)\Reference Assemblies \ Microsoft \Framework\.NETFramework\v4.0\System.Web.dll/ reference:C: \\ Program Files(x86)\ Reference Assemblies \Microsoft\Framework\.NETFramework\v4.0\System.Web.Extensions.dll/ reference:C:\Program Files(x86)\参考组件\Microsoft\Framework\.NETFramework\v4.0\System.Web.Services.dll/ reference:C:\Program Files(x86)\Reference Assemblies \Microsoft\Framework \.NETFramework\v4.0\System.Xml.dll/reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\TenForce。 Execution.Test\bin\Debug\TenForce.Execution.Test.dll /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\ThirdPartyComponents \WathN.Core.dll / debug + / debug:full / optimize- /out:obj\Debug\TenForceExecutionTests.dll / target:library Modules\SecurityModuleTests.cs TestRunSetup.cs TranslateTests.cs WebBaseTest.cs MetaTests.cs IPETests.cs Pages\BasePageTest.cs Properties\AssemblyInfo.cs ServiceAsmxTests.cs Settings.Designer.csD:\Users\arne.de.herdt.TENFORCE2\AppData\Local\Temp\6 \.NETFramework,Version = v4.0.AssemblyAttributes.cs
Microsoft(R)Visual C#2010编译器版本4.0.30319.1
版权所有(C)Microsoft Corporation。版权所有。

从我可以知道,实际WebApplication是

解决方案

显然,这似乎是MSBuild中的一个已知问题,因为更多的人有问题有了这个。
我仍​​然没有收到来自Microsoft的有关此问题的有效答复,但讨论在这里继续: http://social.msdn.microsoft.com/Forums/en-CA/msbuild/thread/434abf1a-30db-4b13-8062-13755898dd71


I'm currently trying to figure out why MSBuild is not able to compile one of our unit test dlls. The problem is only occuring with this DLL and not with the other unit test projects.

This is the output I receive from TeamCity when the build fails:

[10:38:55]: NAnt output:
[10:38:55]: [exec]
[10:38:55]: [exec]
[10:38:55]: [exec] "C:\Robinson\trunk\Projects\Robinson\Robinson.sln" (default target) (1) ->
[10:38:55]: [exec] "C:\Robinson\trunk\Projects\Robinson\TenForceExecutionTests\TenForceExecutionTests.csproj" (default target) (19) ->
[10:38:55]: [exec] (CoreCompile target) ->
[10:38:55]: [exec] Modules\SecurityModuleTests.cs(10,30): error CS0234: The type or namespace name 'Modules' does not exist in the namespace 'TenForce.Execution.Web' (are you missing an assembly reference?) [C:\Robinson\trunk\Projects\Robinson\TenForceExecutionTests\TenForceExecutionTests.csproj]
[10:38:55]: [exec] Modules\SecurityModuleTests.cs(197,39): error CS0246: The type or namespace name 'SecurityModule' could not be found (are you missing a using directive or an assembly reference?) [C:\Robinson\trunk\Projects\Robinson\TenForceExecutionTests\TenForceExecutionTests.csproj]
[10:38:55]: [exec] TranslateTests.cs(10,30): error CS0234: The type or namespace name 'Utils' does not exist in the namespace 'TenForce.Execution.Web' (are you missing an assembly reference?) [C:\Robinson\trunk\Projects\Robinson\TenForceExecutionTests\TenForceExecutionTests.csproj]
[10:38:55]: [exec] IPETests.cs(8,30): error CS0234: The type or namespace name 'Ajax' does not exist in the namespace 'TenForce.Execution.Web' (are you missing an assembly reference?) [C:\Robinson\trunk\Projects\Robinson\TenForceExecutionTests\TenForceExecutionTests.csproj]
[10:38:55]: [exec] Pages\BasePageTest.cs(6,30): error CS0234: The type or namespace name 'Utils' does not exist in the namespace 'TenForce.Execution.Web' (are you missing an assembly reference?) [C:\Robinson\trunk\Projects\Robinson\TenForceExecutionTests\TenForceExecutionTests.csproj]
[10:38:55]: [exec] Pages\BasePageTest.cs(7,30): error CS0234: The type or namespace name 'Pages' does not exist in the namespace 'TenForce.Execution.Web' (are you missing an assembly reference?) [C:\Robinson\trunk\Projects\Robinson\TenForceExecutionTests\TenForceExecutionTests.csproj]
[10:38:55]: [exec] ServiceAsmxTests.cs(9,30): error CS0234: The type or namespace name 'Ajax' does not exist in the namespace 'TenForce.Execution.Web' (are you missing an assembly reference?) [C:\Robinson\trunk\Projects\Robinson\TenForceExecutionTests\TenForceExecutionTests.csproj]
[10:38:55]: [exec] ServiceAsmxTests.cs(10,30): error CS0234: The type or namespace name 'Utils' does not exist in the namespace 'TenForce.Execution.Web' (are you missing an assembly reference?) [C:\Robinson\trunk\Projects\Robinson\TenForceExecutionTests\TenForceExecutionTests.csproj]
[10:38:55]: [exec] Pages\BasePageTest.cs(16,17): error CS0246: The type or namespace name 'basepage' could not be found (are you missing a using directive or an assembly reference?) [C:\Robinson\trunk\Projects\Robinson\TenForceExecutionTests\TenForceExecutionTests.csproj]
[10:38:55]: [exec] ServiceAsmxTests.cs(22,17): error CS0246: The type or namespace name 'Service' could not be found (are you missing a using directive or an assembly reference?) [C:\Robinson\trunk\Projects\Robinson\TenForceExecutionTests\TenForceExecutionTests.csproj]
[10:38:55]: [exec]
[10:38:55]: [exec] 2075 Warning(s)
[10:38:55]: [exec] 10 Error(s)
[10:38:55]: [exec]
[10:38:55]: [exec] Time Elapsed 00:01:40.06

The project TenForceExecutionTests is a simply DLL that contains several UnitTests of the MBunit Framework. This project has a reference to TenForceExecution which is a web application project and another reference to TenForce.Execution.Test, which is another DLL containing logic for both projects.

When we compile everything on the development machine, it works without problems and the compile occurs without errors. On the build agent however this seems to fail...

INFO

  • Target Framework : .NET4
  • OS : Windows XP 32bit
  • Windows 7 SDK Installed

EDIT

Did a clean checkout, and Visual Studio is able to build the entire solution, msbuild however cannot.

EDIT 2

Checked the dependencies:

  • There is a project dependency between the projects
  • There is a solution dependecy between the projects

EDIT 3 When I remove the reference to the webApplication project, and replace it with a reference to the compiled DLL of that project, the errors dissapear and the project compiles fine with MSBuild.

EDIT 4 I've ran the entire build from msbuild through a LOG and took a look at the specific task for compiling the project that's giving problems:

  Task "Csc"
    c:\Windows\Microsoft.NET\Framework\v4.0.30319\Csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\ThirdPartyComponents\ASP.dll /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\BUL\bin\Debug\BUL.dll /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\BULTest\bin\Debug\BULTest.dll /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\DAL\bin\Debug\DAL.dll /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\Framework\bin\Debug\Framework.dll /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\ThirdPartyComponents\Gallio.dll /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\ThirdPartyComponents\Iesi.Collections.dll /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\LanguageResource\bin\Debug\LanguageResource.dll /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\ThirdPartyComponents\log4net.dll /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\ThirdPartyComponents\MbUnit.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll" /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\ThirdPartyComponents\NHibernate.dll /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\PresentationBridge\bin\Debug\PresentationBridge.dll /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\PresentationBridgeTest\bin\Debug\PresentationBridgeTest.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Configuration.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.dll" /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\ThirdPartyComponents\System.Data.SQLite.DLL /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Web.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Web.Extensions.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Web.Services.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Xml.dll" /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\TenForce.Execution.Test\bin\Debug\TenForce.Execution.Test.dll /reference:D:\Users\arne.de.herdt.TENFORCE2\Documents\RobinsonSource\Projects\Robinson\ThirdPartyComponents\WatiN.Core.dll /debug+ /debug:full /optimize- /out:obj\Debug\TenForceExecutionTests.dll /target:library Modules\SecurityModuleTests.cs TestRunSetup.cs TranslateTests.cs WebBaseTest.cs MetaTests.cs IPETests.cs Pages\BasePageTest.cs Properties\AssemblyInfo.cs ServiceAsmxTests.cs Settings.Designer.cs "D:\Users\arne.de.herdt.TENFORCE2\AppData\Local\Temp\6\.NETFramework,Version=v4.0.AssemblyAttributes.cs"
    Microsoft (R) Visual C# 2010 Compiler version 4.0.30319.1
    Copyright (C) Microsoft Corporation. All rights reserved.

From what I can tell, the actuall WebApplication is NOT included in the reference list.

解决方案

Apparently this seems to be a known problem in MSBuild as more people have issues with this. I still haven't received a valid reply from Microsoft regarding this, but the discussion was continued here : http://social.msdn.microsoft.com/Forums/en-CA/msbuild/thread/434abf1a-30db-4b13-8062-13755898dd71

这篇关于MSBuild找不到引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆