将packages.config迁移到PackageReference后,net472项目不再使用MSBuild构建

时间:2019-02-06 14:05:00

标签: asp.net-core msbuild visual-studio-2017 nuget xunit

我有一个net472项目,其中包含我在VS 2017中开发的使用xUnit的单元测试。该项目包含针对ASP.NET Core项目的测试。

我已使用Visual Studio将其packages.config迁移到PackageReference样式。迁移后,它仍然可以在VS中进行构建,但是使用MSBuild进行的构建已被破坏。我收到以下错误:

Project "<solution-file-path>.sln" (2) is building "<project-file-path>.csproj" (14) on node 1 (default targets).
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(186,5): error : Your project file doesn't list 'win-x64' as a "RuntimeIdentifier". You should add 'win-x64' to the "RuntimeIdentifiers" property in your project file and then re-run NuGet restore. [<project-file-path>.csproj]
Done Building Project "<project-file-path>.csproj" (default targets) -- FAILED.

有人暗示原因可能是

2 个答案:

答案 0 :(得分:1)

编辑您的项目文件,并在<TragetFrameworkVersion>之后添加以下属性:

<RuntimeIdentifier>win-x64</RuntimeIdentifier>

那应该可以解决问题。

答案 1 :(得分:0)

我希望其他人都能通过:我在Azure DevOps Build作业中遇到了同样的问题,我不得不添加:

<RuntimeIdentifier>win</RuntimeIdentifier>

.csproj中<TargetFrameworkVersion>之后。

相关问题