Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected error “Your project file doesn’t list ‘win’ as a “RuntimeIdentifier”” occurs when building the solution after enabling “RestoreLockedMode” #10590

Closed
v-crchang opened this issue Feb 22, 2021 · 7 comments · Fixed by NuGet/NuGet.Client#4524
Assignees
Labels
Area:RestoreRepeatableBuild The lock file features Category:Quality Week Issues that should be considered for quality week Functionality:Restore Priority:2 Issues for the current backlog. Type:Bug
Milestone

Comments

@v-crchang
Copy link

v-crchang commented Feb 22, 2021

Details about Problem

NuGet version: NuGet Client Dev\5.10.0.7140
VS Version: Main\31021.18
OS Version: Windows-10-Enterprise-20h1

Repro steps and/or sample project

  1. Create a C# Class Library (.NET Framework) project via VS.
  2. Install a few ‘PackageReference’ packages into the projects.
  3. Set MSBuild property “RestorePackagesWithLockFile” to true in csproj file.
    <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
  4. Do a restore.
  5. Check it should have generated ‘packages.lock.json’ file alongside *.csproj file.
  6. Set msbuild property “RestoreLockedMode” to “true”.
    <RestoreLockedMode>true</RestoreLockedMode>
  7. Install another package.
  8. It should still work fine and update ‘packages.lock.json’ file.
  9. Manually add a new PackageReference item into csproj file.
<PackageReference Include="NUnit">
      <Version>3.12.0</Version>
    </PackageReference>
  1. Perform restore.
  2. Build the solution.

Expected

Only expected error NU1004 shows on error list when building the solution.

Actual

Unexpected error “Your project file doesn’t list ‘win’ as a “RuntimeIdentifier”” occurs when building the solution as below screenshot.
image

Notes

  1. This issue doesn’t repro on .NET Core projects.
  2. The issue starts from Dev\5.9.0.7086.
@zkat zkat added Area:RestoreRepeatableBuild The lock file features Priority:2 Issues for the current backlog. Type:Bug Functionality:Restore labels Feb 25, 2021
@aortiz-msft
Copy link
Contributor

@nkolev92 - Would you mind taking a look?

@nkolev92
Copy link
Member

Only expected error NU1004 shows on error list when building the solution.

I'm not confident this we can rely on this as an assumption.
This is invalid restore scenario, so what other components do post restore is not fully in our control.

If you had actual code in any of your projects, then at build time, you'd get many other other errors telling you that it can't resolve certain types.

There's a chance we can avoid this particular message. We create dummy targets. I'll take a look during Quality Week.
I think the pri 2 label makes sense for now.

@nkolev92 nkolev92 added the Category:Quality Week Issues that should be considered for quality week label Mar 10, 2021
@nkolev92 nkolev92 self-assigned this Mar 10, 2021
@nkolev92 nkolev92 added this to the Sprint 2021-03 milestone Mar 10, 2021
@nkolev92 nkolev92 removed this from the Sprint 2021-05 milestone Jun 7, 2021
@kartheekp-ms
Copy link
Contributor

kartheekp-ms commented Jul 2, 2021

I found this issue while working on a VS feedback ticket with similar error message https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1348331.

I followed the repro steps mentioned in the issue description on Dev17 and noticed only 1 error NU1004 in the error list window.

image

@nkolev92
Copy link
Member

SDK based proejcts won't have this issue since the defaults are different.

@michal-ciechan
Copy link

michal-ciechan commented Dec 8, 2022

Is there a workaround for this? Getting this all of a sudden since upgrading to .NET 7 when trying to build an old style .csproj (which used to build fine, and is building fine on build server which doesn't have .NET 7 or related tools)

Microsoft.NuGet.targets(198, 5): 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.

Edit: Updating my Visual Studio 22 to latest version, restart + loading the project has fixed it (and it asked to download .NET Desktop Development tools)

@k0zi
Copy link

k0zi commented Sep 20, 2023

Clean the project (delete obj and bin directory) and build it again.

@trivalik
Copy link

trivalik commented Oct 25, 2023

This could happen in case you upgrade a project to new SDK Project style, but then later you checkout a old commit with old project type and then it is required to delete obj/bin folder like @k0zi already stated. In my case it was important to close Visual Studio during deleting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:RestoreRepeatableBuild The lock file features Category:Quality Week Issues that should be considered for quality week Functionality:Restore Priority:2 Issues for the current backlog. Type:Bug
Projects
None yet
9 participants