net472 project no longer builds using MSBuild after migrating packages.config to PackageReference
Asked Answered
H

2

10

I have a net472 project containing unit tests using xUnit, which I develop in VS 2017. The project contains tests for an ASP.NET Core project.

I have migrated its packages.config to the PackageReference style using Visual Studio. It still builds in VS after migration, but building using MSBuild was broken. I get the following error:

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.

Anyone has a hint what the reason could be?

Hairdo answered 6/2, 2019 at 14:5 Comment(1)
You have a net472 project to test (and of course reference to) the core project? How can he compile at all?Crossbar
G
8

Edit you project file and add the following property after <TragetFrameworkVersion>:

<RuntimeIdentifier>win-x64</RuntimeIdentifier>

That should solve the issue.

Garges answered 6/2, 2019 at 14:24 Comment(0)
S
6

I case others get by: I had the same issue on Azure DevOps Build jobs and I had to add:

<RuntimeIdentifier>win</RuntimeIdentifier>

after <TargetFrameworkVersion> in the .csproj.

Shir answered 7/4, 2020 at 14:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.