Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuild cannot find a reference

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.

like image 240
codingbunny Avatar asked Jun 22 '11 08:06

codingbunny


People also ask

Why MSBuild doesn't copy DLL references?

MSBuild doesn't copy references (DLL files) if using project dependencies in solution 99 .NET 4.0 build issues on CI server 143 Install Windows Service created in Visual Studio 220 The type or namespace name does not exist in the namespace 'System.Web.Mvc'

Is there a project dependency between the projects in MSBuild?

EDIT 2 Checked the dependencies: There is a project dependency between the projects There is a solution dependecy between the projects EDIT 3When 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.

Why is MSBuild not working in Visual Studio 2017?

This error occurs when the project has not been restored first. Please run this from a "Developer command prompt for VS 2017" then run msbuild. 06-11-2019 11:24 PM

What is the DotNet MSBuild command?

The dotnet msbuild command allows access to a fully functional MSBuild. The command has the exact same capabilities as the existing MSBuild command-line client for SDK-style projects only. The options are all the same. For more information about the available options, see the MSBuild command-line reference.


2 Answers

Had the same issue today, ended that the project that could not be referenced had a different platform specified, x86 where the other projects where Any Platform. To get around this, I had to set the parameter with /p:Platform="Mixed Platforms". You can see what VS uses by going to Configuration Manager and looking at the Active Solution Platform selected in the top right.

like image 198
Cobus Bernard Avatar answered Oct 11 '22 11:10

Cobus Bernard


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

like image 20
codingbunny Avatar answered Oct 11 '22 11:10

codingbunny