Kris Harper
Kris Harper

Reputation: 5862

Msbuild fails building website project with an indirect reference to System.Runtime

I am running into a dependency issue with MSBuild. I added a NuGet package for Microsoft.Tpl.Dataflow to a project in my solution. This is causing a build failure for a website project in the solution which references the first project. There seems to be an issue with getting the correct runtime version.

This is one of the many errors I get when building the solution with MSBuild.

C:\src\MyWebsite.metaproj : warning MSB3268: The primary reference "C:\src\projects\ReferencedProject\bin\Debug\ReferencedProject.dll" could not be resolved because it has an indirect dependency on the framework assembly "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.5". To resolve this problem, either remove the reference "C:\src\projects\ReferencedProject\bin\Debug\ReferencedProject.dll" or retarget your application to a framework version which contains "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".

The confusing thing to be is that the solution builds fine in Visual Studio. Also, all the other projects in the solution build—it's only the website projects that are failing.

I have tried

I still can't get it to build. How can I fix this?

Upvotes: 5

Views: 1336

Answers (1)

Kris Harper
Kris Harper

Reputation: 5862

Turns out aspnet_compiler.exe (which is called by msbuild) does not look for libraries in the Facade directory at

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\Facade

and as such, the website project in the solution would not compile.

I found this out from this blog post. As mentioned there, to fix the problem I copied the DLLs from the Facade directory into the v4.5 directory and everything works.

To be honest this is a less than ideal solution.

Upvotes: 5

Related Questions