'dotnet build' error after migrating dotnetcore project to 1.0.4

旧时模样 提交于 2019-12-06 03:52:43

The .NET Core build of MSBuild that is included in the .NET Core CLI is capable of building classic projects on windows machines as well as long as they target .NET Framework >= 4.0, reference assemblies are installed and no special targets / tasks are used.

In your case, you tried to compile a resource with a different architecture than the host MSBuild instance is. This is worked around in SDK-based projects beginning in the upcoming 2.0 tools but classic projects rely on MSBuild to launch an additional process using a different CLR - which is not supported on .NET Core.

The easy way to work around it is to not use the dotnet commands to restore / build the solution, but their msbuild equivalents using the msbuild.exe installed with visual studio using the developer command prompt. (e.g. => msbuild /t:Restore, msbuild, msbuild /t:Publish /p:Configuration=Release etc.).

Another workaround would be to edit the problematic csproj file to add this to the <Project> in the "old" project:

<PropertyGroup Condition="'$(MSBuildRuntimeType)' == 'Core'">
  <GenerateResourceMSBuildArchitecture>CurrentArchitecture</GenerateResourceMSBuildArchitecture>
  <GenerateResourceMSBuildRuntime>CurrentRuntime</GenerateResourceMSBuildRuntime>
</PropertyGroup>

There is an issue on MSBuild's GitHub repo about this problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!