【问题标题】:net472 project no longer builds using MSBuild after migrating packages.config to PackageReference将 packages.config 迁移到 PackageReference 后,net472 项目不再使用 MSBuild 构建
【发布时间】:2019-02-06 14:05:00
【问题描述】:

我有一个 net472 项目,其中包含使用 xUnit 的单元测试,我在 VS 2017 中开发该项目。该项目包含 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.

谁有提示可能是什么原因?

【问题讨论】:

  • 您有一个net472 项目要测试(当然还有参考)core 项目?他怎么可能编译?

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


【解决方案1】:

编辑你的项目文件并在&lt;TragetFrameworkVersion&gt;之后添加以下属性:

<RuntimeIdentifier>win-x64</RuntimeIdentifier>

这应该可以解决问题。

【讨论】:

    【解决方案2】:

    我认为其他人可以通过:我在 Azure DevOps Build 作业中遇到了同样的问题,我不得不补充:

    <RuntimeIdentifier>win</RuntimeIdentifier>
    

    在 .csproj 中的 &lt;TargetFrameworkVersion&gt; 之后。

    【讨论】:

      猜你喜欢
      • 2020-07-20
      • 1970-01-01
      • 2023-02-04
      • 1970-01-01
      • 1970-01-01
      • 2021-12-08
      • 2019-12-25
      • 2019-02-11
      • 1970-01-01
      相关资源
      最近更新 更多