Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# MSBuild找不到引用_C#_Visual Studio 2010_Msbuild_Continuous Integration - Fatal编程技术网

C# MSBuild找不到引用

C# MSBuild找不到引用,c#,visual-studio-2010,msbuild,continuous-integration,C#,Visual Studio 2010,Msbuild,Continuous Integration,我目前正试图弄清楚为什么MSBuild无法编译我们的单元测试DLL之一。这个问题只发生在这个DLL中,而不发生在其他单元测试项目中 这是我在构建失败时从TeamCity收到的输出: [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) ->

我目前正试图弄清楚为什么MSBuild无法编译我们的单元测试DLL之一。这个问题只发生在这个DLL中,而不发生在其他单元测试项目中

这是我在构建失败时从TeamCity收到的输出:

[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
项目TenForceExecutionTests是一个简单的DLL,其中包含MBunit框架的几个单元测试。此项目引用了TenForce.Execution,这是一个web应用程序项目,另一个引用了TenForce.Execution.Test,这是另一个包含两个项目逻辑的DLL

当我们在开发机器上编译所有东西时,它工作正常,编译过程中没有错误。但在构建代理上,这似乎失败了

信息

  • 目标框架:.NET4
  • 操作系统:Windows XP 32位
  • 已安装Windows 7 SDK
编辑

执行了干净的签出,并且Visual Studio能够生成整个解决方案,但msbuild无法

编辑2

检查依赖项:

  • 项目之间存在项目依赖关系
  • 项目之间存在解决方案依赖关系
编辑3 当我删除对webApplication项目的引用,并将其替换为对该项目已编译DLL的引用时,错误消失,项目可以使用MSBuild进行良好编译

编辑4 我已经通过一个日志从msbuild运行了整个构建,并查看了编译出现问题的项目的特定任务:

  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.

据我所知,实际的Web应用程序未包含在参考列表中。

如果您对计算机上的新文件夹进行了干净的签出,它在那里也可以工作吗


大多数情况下,出现这些问题是因为您引用了本地可用但不在源代码管理中的内容。这是一个很好的检查,以查看构建项目所需的所有内容是否都被正确引用并在源代码管理下。

我还遇到了一个问题,即从VS构建并不总是与简单使用msbuild相同。然后,帮助我创建msbuild运行日志(/fl开关)并检查日志,跟踪生成步骤并尝试查找有问题的任务。

显然,这似乎是msbuild中的一个已知问题,因为越来越多的人对此有问题。
关于这一点,我还没有收到微软的有效回复,但讨论仍在继续:

我知道这是一篇老文章,但我今天看到了它,所以我想我会为其他人提供反馈


我曾多次遇到过这种情况,并发现将目标框架从.NET Framework 4客户端配置文件更改为.NET Framework 4就可以做到这一点。

今天也遇到了同样的问题,即无法引用的项目指定了不同的平台,x86,而其他项目指定了任何平台。为了解决这个问题,我必须使用/p:Platform=“Mixed Platforms”设置参数。通过转到Configuration Manager并查看右上角选定的活动解决方案平台,您可以看到VS使用了什么。

我检查了丢失的dll属性,发现程序集名称与默认命名空间具有相同的名称。
然后,我将程序集名称更改为其他名称,解决了我的问题。

我也遇到过同样的问题

我真的很怀疑,当我们通过MSBuild和Jenkins运行解决方案文件时,为什么MSBuild会抛出缺少的程序集引用,但它在Visual Studio中工作得很好,经过两天的斗争,我发现了一个结论

我编写了一个批处理脚本,首先通过VisualStudio运行解决方案文件,然后运行解决方案文件。它工作不好

您只需调用批处理脚本,然后运行MSBuild/Jenkins

批处理脚本:

cd C:\Program Files(x86)\Microsoft Visual Studio 14.0\Common7\IDE devenv“C:\Program Files(x86)\Jenkins\workspace\TFS\Product\solution.sln”/Rebuild

devenv:在命令行中运行Visual Studio

注意:如果您在服务器中运行MSBuild/Jenkins,则确实需要Visual Studio


请给我发邮件,询问与此相关的任何问题………

在发布模式下使用MSBuild构建解决方案时,我遇到了此错误消息,即使调试模式工作正常,并且两者都在Visual Studio中工作。结果在解决方案设置中,该项目未配置为针对“Release | Mixed Platform”或“Release | Any CPU”构建。

我尝试使用AnyCPU和Preferred-32位,但仍然不起作用。还尝试了使用AnyCPU而不检查Prefer-32位,但没有任何效果。我在使用竹子部署代码时遇到了这个问题。我确保我的包都签入了代码(因为我的nuget restore在Bambol中有问题),并确保我在项目中的dll引用正在查看其路径中的包。我通过从.gitignore文件中删除/packages来签入包。此外,还更新了项目中的my packages.config文件,以提及要使用的包和版本。 例如:
此外,请确保运行部署任务的代理具有所需的.NET framework版本。通过以上所有更改,我可以解决此参考问题。

在构建UWP appx包时,我还发现了类似的参考问题。有许多错误消息如下所示:

App.xaml.cs(6,15):错误CS0234:命名空间“Windows”中不存在类型或命名空间名称“ApplicationModel”(是否缺少程序集引用?

如果使用VS2017打开sln文件,则不会产生任何问题

我做了两件事来解决这个问题:

  • 我注意到原来的解决方案需要winSDK 10.0.18362,但在
        msbuild mySolution.sln /p:Configuration="Release" /p:Platform="x64" /t:restore
        msbuild mySolution.sln /p:Configuration="Release" /p:Platform="x64"