msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

MSBuild fails when building solution with project dependencies

Open NikitaGolovko opened this issue 6 years ago • 4 comments

The build for my solution, which contains multiple projects, suddenly appears to be broken and the cause of the issue isn't clear. All of the projects in the solution target the same framework (4.5.1), however some of the projects' dependencies might be targeting an earlier version of the framework. As of last week, we were able to successfully build solutions that fall under this scenario. Starting last Thursday, the builds appear to be broken without any changes to the build server or the solution.

To illustrate and remove some of the complexities with our production setup, I created a sample solution which mimics the behaviour.

Project structure:

  • CBI Solution
    • CBI website
    • CBI Implementation Library
    • CBI Core library, defining the interfaces

Target Framework Version for the website and class libraries is 4.5.1

Replication Steps

Solution 1 Github repo: https://github.com/NikitaGolovko/Solution1.git

Build, using MSBuild 14. My command is:

msbuild.exe "%SOLUTION1PATH%\CBILite.sln" /p:platform="Any CPU" /p:configuration="Release" /v:d

Output

C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v /localhost_61806 -p cbi\ -u -f PrecompiledWeb\lo
calhost_61806\
Microsoft (R) ASP.NET Compilation Tool version 4.7.2046.0
Utility to precompile an ASP.NET application
Copyright (C) Microsoft Corporation. All rights reserved.


Done executing task "AspNetCompiler".
Task "Message" skipped, due to false condition; (!((false) or ('$(AspNetConfiguration)' == 'Debug') or ('$(AspNetConfig
uration)' == 'Release'))) was evaluated as (!((false) or ('Release' == 'Debug') or ('Release' == 'Release'))).
Done building target "Build" in project "cbi.metaproj".
Done Building Project "D:\Work\DotNet\Nikita\Solution1\cbi.metaproj" (default targets).

Done executing task "MSBuild".
Done building target "Build" in project "CBILite.sln".
Done Building Project "D:\Work\DotNet\Nikita\Solution1\CBILite.sln" (default targets).


Build succeeded.
  0 Warning(s)
  0 Error(s)

Time Elapsed 00:00:03.10

Full output is located here: https://github.com/NikitaGolovko/Solution1/blob/master/MSBuild_Output.txt

Solution 2

Github Repo: https://github.com/NikitaGolovko/Solution2.git

Solution is nearly identical to the Solution1, with the only exception being a dependency for Unity in CBI Implementation library. To simplify the process and eliminate the nuget restore step, I have included nuget packages with the solution.

Build, using MSBuild 14. My command is:

msbuild.exe "%SOLUTION2PATH%\CBILite.sln" /p:platform="Any CPU" /p:configuration="Release" /v:d

Output

  C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v /localhost_61806 -p cbi\ -u -f PrecompiledWeb\lo
  calhost_61806\
  Microsoft (R) ASP.NET Compilation Tool version 4.7.2046.0
  Utility to precompile an ASP.NET application
  Copyright (C) Microsoft Corporation. All rights reserved.

D:\Work\DotNet\Nikita\Solution2\cbi\Index.aspx.vb(5): error BC30002: Type 'CBILite.Calculator' is not defined. [D:\Work
\DotNet\Nikita\Solution2\cbi.metaproj]
  The command exited with code 1.

Done executing task "AspNetCompiler" -- FAILED.
Done building target "Build" in project "cbi.metaproj" -- FAILED.
Done Building Project "D:\Work\DotNet\Nikita\Solution2\cbi.metaproj" (default targets) -- FAILED.

Done executing task "MSBuild" -- FAILED.
Done building target "Build" in project "CBILite.sln" -- FAILED.
Done Building Project "D:\Work\DotNet\Nikita\Solution2\CBILite.sln" (default targets) -- FAILED.


Build FAILED.

Full output is located here: https://github.com/NikitaGolovko/Solution2/blob/master/MSBuild_Output.txt

Observations

Bin folder When looking in the bin folder of the website, I notice that CBILite.dll is missing after the build for Solution2, but present in Solution1.

TargetFrameworkVersion Passing TargetFrameworkVersion in the MSBuild arguments does not appear to influence the build. I have attempted to pass 4.5, 4.5.1 to no avail. HOWEVER passing 3.5 results in the successful build. This is extremely strange.

Metaproj When comparing Metaproj files generated for both solutions, the only observable and seemingly important difference is the lack of the TargetFrameworkVersion element. Solution1 (without dependencies), contains <TargetFrameworkVersion>v.4.0</TargetFrameworkVersion> element. Solution2 (with the dependency) does not. I didn't include metaproj files in the repo, but can share them if needed.

Additional thoughts

The issue manifested itself rather suddenly and seems to be affecting most of our solutions that have mixed projects (C#/VB + website). Web Projects continue to function normally.

I have exhausted all my options at this point and haven't been able to find a solution.

Issues #2191 and #1915 might be related, but I am uncertain, since they're targeting different frameworks and steps described in those issues are lacking some details.

NikitaGolovko avatar Sep 29 '17 15:09 NikitaGolovko

any update on this?

SimonCropp avatar Dec 17 '17 01:12 SimonCropp

any update on this?

imakowski avatar Sep 30 '18 22:09 imakowski

any update on this?

senhorlopes avatar Oct 11 '18 11:10 senhorlopes

+1 experiencing the same issue @NikitaGolovko did you manage to work around the issue?

broomfn avatar Jun 30 '22 06:06 broomfn