VS 15.8.2 broke build tools - missing RuntimeIdentifier

The last windows update has broken our whole build chain and I am a little at a loss at what causes it.

I have a legacy project that is a VS 2017 dolution with a significant number of projects (winform, couple web based, some Webapi only).

Locally things work perfectly. I can just build them.

On the server, the proejct has started to fail, and the error is:

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(186,5): Error : Your project file doesn't list 'win' as a "RuntimeIdentifier". You should add 'win' to the "RuntimeIdentifiers" property in your project file and then re-run NuGet restore.

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(186,5): Error : Your project file doesn't list 'win' as a "RuntimeIdentifier". You should add 'win' to the "RuntimeIdentifiers" property in your project file and then re-run NuGet restore.

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(186,5): Error : Your project file doesn't list 'win' as a "RuntimeIdentifier". You should add 'win' to the "RuntimeIdentifiers" property in your project file and then re-run NuGet restore.

Process 'msbuild.exe' exited with code '1'.

I have added

<RuntimeIdentifiers>win</RuntimeIdentifiers>

To a number of projects. No change. I am at a loss, because the error message does not even tell me which project.


Solution 1:

At some point before attempting to build, you need to delete the obj folder. More than one person showed this to solve the problem.

https://developercommunity.visualstudio.com/content/problem/312180/projects-fail-to-build-in-1580-due-to-errors-from.html

Solution 2:

Although @Señor CMasMas's answer has helped me in the past, I'm now finding (since installing the .NET Core SDK v2.2 - I don't know if that's related though) that I also need to close and reopen Visual Studio. So for me the recipe is:

  • Clean solution
  • Delete obj folders
  • Delete the .vs folder (optional, if you get red lines but it builds OK)
  • Close and reopen Visual Studio
  • Then build

Solution 3:

Add this: <RuntimeIdentifier>win</RuntimeIdentifier> to your project file, for example after element TargetFrameworkVersion. Make sure the element name is singular. RuntimeIdentifiers on the other hand is used in the new csproj format

Solution 4:

Or you just can run in the root directory of your project the script in PowerShell that you should run as administrator.

Get-ChildItem .\ -include bin,obj -Recurse | foreach { remove-item $_.fullname -Force -Recurse }

this script will delete all obj and bin folders