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

NU1004 The project's runtime identifiers have changed - ".NETFramework,Version=v4.8/win-arm64" #12711

Closed
fowl2 opened this issue Jun 28, 2023 · 1 comment
Labels
Area:RestoreRepeatableBuild The lock file features Functionality:Restore Resolution:ByDesign This issue appears to be ByDesign Resolution:NotABug This issue appears to not be a bug Type:Bug

Comments

@fowl2
Copy link

fowl2 commented Jun 28, 2023

Not sure if this should be here or dotnet/runtime but the error starts with "NU" so I'm starting here :)

Have started receiving this error message building my non-sdk style project:

NU1004: The project's runtime identifiers have changed from. Project's runtime identifiers: win;win-arm64;win-x64;win-x86, lock file's runtime identifiers win;win-x64;win-x86.The packages lock file is inconsistent with the project dependencies so restore can't be run in locked mode. Disable the RestoreLockedMode MSBuild property or pass an explicit --force-evaluate option to run restore to update the lock file.

Example project snippet:

  <PropertyGroup>
    <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
    <RestoreLockedMode>true</RestoreLockedMode>
  </PropertyGroup>
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{A18391D4-B581-4B3E-9022-0F4ED54FD7C1}</ProjectGuid>
    <OutputType>Library</OutputType>
    <TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <TargetFrameworkProfile />
    <NuGetPackageImportStamp>
    </NuGetPackageImportStamp>
  </PropertyGroup>

I was under the understanding that arm64 support was only being added to .Net Framework 4.8.1 (note the extra .1) to avoid this kind of problem.

The workaround is to regenerate the packages.lock.json file which adds in the ".NETFramework,Version=v4.8/win-arm64": { part. Not sure if this break building the project in older versions of Visual Studio, etc. Regardless it's unexpected and unwanted churn to have a broken build like this.

Nuget Version: 6.6.1+f4f3bb12a1ccbb974bca9b115a7b7291a7d6fb39.f4f3bb12a1ccbb974bca9b115a7b7291a7d6fb39
Platform: Azure DevOpos Hosted Agent 20230620.1.0 (windows-2022)

@zivkan zivkan added Type:Bug Resolution:ByDesign This issue appears to be ByDesign Functionality:Restore Resolution:NotABug This issue appears to not be a bug Area:RestoreRepeatableBuild The lock file features labels Jun 28, 2023
@zivkan
Copy link
Member

zivkan commented Jun 28, 2023

@fowl2 This is due to Visual Studio's build tools adding win-arm64as a default RID: dotnet/NuGet.BuildTasks#156

As you can see from the pull request, they don't contition this to happen only on .NET Framework 4.8.1 or above, it's always added when the RuntimeIdentifiers property isn't already set. If you don't agree with this behaviour, you could try creating an issue in that repo (despite the name, the repo is owned by a different team in Microsoft, not the NuGet team, they just named it like that because it reads the file that NuGet writes), but I think you'd have better luck reporting it to developercommunity.visualstudio.com (via Visual Studio's report a problem feature).

Therefore, another mitigation is to set the RuntimeIdentifiers in your own project explicitly, so you're not subject to changing defaults.

From NuGet's point of view, NuGet is running as instructed. It's told to restore a few RIDs, including win-arm64, and it's also told to restore in locked mode, and the lock file doesn't contain the the arm64 RID. Therefore, sorry if this seems blunt, but it's not a NuGet bug, so I'm closing this here.

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 Functionality:Restore Resolution:ByDesign This issue appears to be ByDesign Resolution:NotABug This issue appears to not be a bug Type:Bug
Projects
None yet
Development

No branches or pull requests

2 participants