Unable to build for OS 10: Unable to find package Microsoft.Windows.SDK.NET.Ref

Joseph Stateson 46 Reputation points
2023-08-05T01:28:32.33+00:00

Have looked at this problem for 3 days. I cannot build NET6 for OS 10 on my dev system. I can build for os7 or os8 using the simplest "WinFormsApp1"

I tried several suggestions googling that "NuGet restore" but none worked

[App Property Image] (this did not work so I pasted the image below)
--and--image

On another win11 system I did a clean install of VS2022 and had no problem building for NET6 OS 10 that exact sample app.

The only difference I can tell is that VS2022 on my system has extensive c++ development and my VS2022 has been upgrade from early versions of VS2022 unlike the fresh install that was basically C#

What I have tried

repaired VS2022

manually deleted the nupkg at C:\Program Files\dotnet\library-packs and reinstall MAUI SDK. This actually got me the latest versions of those nupkg unlike just removing MAUI and then adding it back in using the installer

Brought up VS2022 "about" on both systems, did a "copy info" on each and looked, comparing (as best as I could) to see if I was missing something on my development system.

Tried the following

C:\Users\josep\Downloads>nuget restore c:\Users\josep\source\repos\WinFormsApp1
MSBuild auto-detection: using msbuild version '17.6.3.22601' from 'C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\bin'.
Restoring packages for c:\Users\josep\source\repos\WinFormsApp1\WinFormsApp1.csproj...
NU1101: Unable to find package Microsoft.Windows.SDK.NET.Ref. No packages exist with this id in source(s): C:\Program Files\dotnet\library-packs, Package source
Generating MSBuild file c:\Users\josep\source\repos\WinFormsApp1\obj\WinFormsApp1.csproj.nuget.g.props.
Writing assets file to disk. Path: c:\Users\josep\source\repos\WinFormsApp1\obj\project.assets.json
Failed to restore c:\Users\josep\source\repos\WinFormsApp1\WinFormsApp1.csproj (in 457 ms).

I do not know what else to do other than using revo uninstaller and removing VS2022 community for a clean install.

the above did not work either

Is there a xml or config file for Visual Studio Installer that I can copy from the working system over to the one that cannot build OS 10?

I did the export and import but still did not work. I also installed VS2022 on another system, win11, and it worked fine. Just cannot get past that SDK missing.

wfa-bug-1

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,891 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,928 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Joseph Stateson 46 Reputation points
    2023-08-06T04:00:16.51+00:00

    I created another admin user, signed out of my account and into the new account.

    VS 2022 was able to build the windows 10 version just fine.

    It would really be useful if I could get VS 2022 to work using my original account. Looks like I got to sign in with an alternate account for now.

    0 comments No comments

  2. Mark 0 Reputation points
    2023-10-18T05:55:02.6433333+00:00

    I had the same, since I did not want to change my user, I did the following.

    Delete all the data from

    • C:\User\xxxx\AppData\Local\Microsoft\VisualStudio
    • C:\Users\xxxx\AppData\Roaming\Microsoft\VisualStudio

    Start Visual Studio again, and VS rebuilds its env.

    I could work normal again

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.