Home > front end >  NU1102 Unable to find package Microsoft.WindowsDesktop.App.Ref with version (= 6.0.12)
NU1102 Unable to find package Microsoft.WindowsDesktop.App.Ref with version (= 6.0.12)

Time:11-24

create a brand new asp net core web api in visual studio 2022 version (17.4.1) targeting .net 6

the solution won't build, and we got this error

Error NU1102 Unable to find package Microsoft.WindowsDesktop.App.Ref with version (= 6.0.12)

CodePudding user response:

Finally I found a workaround for this problem

global.json fixes the problem

{
  "sdk": {
    "version": "6.0.0",
    "rollForward": "latestMinor",
    "allowPrerelease": false
  }
}

If you want to use the latest SDK version that is installed on your machine, no global.json file is needed. however, you typically want to specify an acceptable range for the SDK version that is used. The global.json file has a rollForward feature that provides flexible ways to specify an acceptable range of versions.

The .NET SDK looks for a global.json file in the current working directory (which isn't necessarily the same as the project directory) or one of its parent directories.

https://learn.microsoft.com/en-us/dotnet/core/tools/global-json

That's all it worked for me :)

  • Related