简体   繁体   English

Msbuild无法使用间接引用System.Runtime来构建网站项目

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

I am running into a dependency issue with MSBuild. 我遇到了MSBuild的依赖项问题。 I added a NuGet package for Microsoft.Tpl.Dataflow to a project in my solution. 我向解决方案中的项目添加了Microsoft.Tpl.Dataflow的NuGet程序包。 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. 这是在使用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. C:\\ src \\ MyWebsite.metaproj:警告MSB3268:无法解析主引用“ C:\\ src \\ projects \\ ReferencedProject \\ bin \\ Debug \\ ReferencedProject.dll”,因为它间接依赖于框架程序集“系统”。运行时,版本= 4.0.0.0,文化=中性,PublicKeyToken = b03f5f7f11d50a3a”,当前目标框架中无法解决。 ".NETFramework,Version=v4.5". ” .NETFramework,版本= 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". 要解决此问题,请删除引用“ C:\\ src \\ projects \\ ReferencedProject \\ bin \\ Debug \\ ReferencedProject.dll”,或将应用程序重新定位到包含“ System.Runtime,Version = 4.0.0.0,Culture =中性,PublicKeyToken = b03f5f7f11d50a3a”。

The confusing thing to be is that the solution builds fine in Visual Studio. 令人困惑的是该解决方案在Visual Studio中构建良好。 Also, all the other projects in the solution build—it's only the website projects that are failing. 此外,解决方案中的所有其他项目都已构建-只有网站项目失败了。

I have tried 我努力了

  • Changing the target framework for the website to 4.0 (it's currently 4.5). 将网站的目标框架更改为4.0(当前为4.5)。
  • Adding an assembly reference to System.Runtime.dll version 4.0.0.0 将程序集引用添加到System.Runtime.dll版本4.0.0.0

I still can't get it to build. 我仍然无法建立它。 How can I fix this? 我怎样才能解决这个问题?

Turns out aspnet_compiler.exe (which is called by msbuild) does not look for libraries in the Facade directory at 事实证明,aspnet_compiler.exe(由msbuild调用)不在Facade目录中查找库。

C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework.NETFramework\\v4.5\\Facade C:\\ Program Files(x86)\\ Reference Assemblys \\ 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. 如此处所述,为解决此问题,我将DLL从Facade目录复制到v4.5目录中,一切正常。

To be honest this is a less than ideal solution. 老实说,这不是一个理想的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM