sdk icon indicating copy to clipboard operation
sdk copied to clipboard

`dotnet workload` fails with KeyNotFoundException after updating SDKs

Open mstefarov opened this issue 1 year ago • 8 comments

Describe the bug

I have VS 17.3 and VSPreview 17.4 installed side-by-side, and I just updated both to latest versions (17.3.5 and 17.4pre2.1). Since the update, my builds started failing with NETSDK1 "missing workload" errors. So I ran dotnet workload restore and it failed with an exception:

PS R:\foo> dotnet workload restore .\src\Foo\Foo.csproj
__________________________________________________
Project "R:\foo\src\Foo\Foo.csproj" (_GetRequiredWorkloads target(s)):

__________________________________________________
Project "R:\foo\src\Foo\Foo.csproj" is building "R:\foo\src\Foo\Foo.csproj" (_GetRequiredWorkloads target(s)):

Done building project "Foo.csproj".
Installing workloads:

Workload installation failed: One or more errors occurred. (The given key 'Microsoft.iOS.Sdk' was not present in the dictionary.)

I ran dotnet workload repair. It claims to have repaired "ios" and "maui" workloads, but my build error and the dotnet-workload exceptions did not go away.

"dotnet workload repair" output
PS R:\foo> dotnet workload repair

Repairing workload installation for workloads: ios maui
Downloading Microsoft.iOS.Sdk.Msi.x64 (15.4.447)
Installing Microsoft.iOS.Sdk.15.4.447.447-x64.msi ....... Done
Downloading Microsoft.iOS.Windows.Sdk.Msi.x64 (15.4.447)
Installing Microsoft.iOS.Windows.Sdk.15.4.447.447-x64.msi ....... Done
Downloading Microsoft.iOS.Ref.Msi.x64 (15.4.447)
Installing Microsoft.iOS.Ref.15.4.447.447-x64.msi ..... Done
Downloading Microsoft.iOS.Runtime.ios-arm.Msi.x64 (15.4.447)
Installing Microsoft.iOS.Runtime.ios-arm.15.4.447.447-x64.msi ...... Done
Downloading Microsoft.iOS.Runtime.ios-arm64.Msi.x64 (15.4.447)
Installing Microsoft.iOS.Runtime.ios-arm64.15.4.447.447-x64.msi ..... Done
Downloading Microsoft.iOS.Runtime.iossimulator-x86.Msi.x64 (15.4.447)
Installing Microsoft.iOS.Runtime.iossimulator-x86.15.4.447.447-x64.msi ...... Done
Downloading Microsoft.iOS.Runtime.iossimulator-x64.Msi.x64 (15.4.447)
Installing Microsoft.iOS.Runtime.iossimulator-x64.15.4.447.447.msi ...... Done
Downloading Microsoft.iOS.Runtime.iossimulator-arm64.Msi.x64 (15.4.447)
Installing Microsoft.iOS.Runtime.iossimulator-arm64.15.4.447.447-x64.msi ...... Done
Downloading Microsoft.iOS.Templates.Msi.x64 (15.4.447)
Installing Microsoft.iOS.Templates.15.4.447.447-x64.msi .... Done
Repairing Microsoft.Mono.ios-arm.6.0.9-x64.msi ........ Done
Repairing Microsoft.Mono.ios-arm64.6.0.9-x64.msi ........ Done
Repairing Microsoft.Mono.iossimulator-arm64.6.0.9-x64.msi ........ Done
Repairing Microsoft.Mono.iossimulator-x64.6.0.9.msi ........ Done
Repairing Microsoft.Mono.iossimulator-x86.6.0.9-x64.msi ....... Done
Repairing Microsoft.MonoAOTCompiler.Task.6.0.9-x64.msi .... Done
Repairing Microsoft.MonoTargets.Sdk.6.0.9-x64.msi ..... Done
Downloading Microsoft.Maui.Core.Ref.android.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Core.Ref.android.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Core.Runtime.android.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Core.Runtime.android.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Controls.Ref.android.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Controls.Ref.android.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Controls.Runtime.android.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Controls.Runtime.android.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Essentials.Ref.android.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Essentials.Ref.android.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Essentials.Runtime.android.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Essentials.Runtime.android.6.0.536.0-x64.msi .... Done
Downloading Microsoft.AspNetCore.Components.WebView.Maui.Msi.x64 (6.0.536)
Repairing Microsoft.AspNetCore.Components.WebView.Maui.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Dependencies.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Dependencies.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Sdk.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Sdk.6.0.536.0-x64.msi ..... Done
Downloading Microsoft.Maui.Extensions.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Extensions.6.0.536.0-x64.msi .... Done
Repairing Microsoft.Maui.Graphics.6.0.403-x64.msi .... Done
Downloading Microsoft.Maui.Resizetizer.Sdk.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Resizetizer.Sdk.6.0.536.0-x64.msi ...... Done
Downloading Microsoft.Maui.Templates-6.0.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Templates-6.0.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Core.Ref.any.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Core.Ref.any.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Core.Runtime.any.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Core.Runtime.any.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Controls.Ref.any.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Controls.Ref.any.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Controls.Runtime.any.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Controls.Runtime.any.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Essentials.Ref.any.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Essentials.Ref.any.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Essentials.Runtime.any.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Essentials.Runtime.any.6.0.536.0-x64.msi .... Done
Repairing Microsoft.Android.Sdk.Windows.32.0.448-x64.msi .......... Done
Repairing Microsoft.Android.Ref.31.32.0.448-x64.msi ...... Done
Repairing Microsoft.Android.Runtime.31.android-arm.32.0.448-x64.msi ..... Done
Repairing Microsoft.Android.Runtime.31.android-arm64.32.0.448-x64.msi ..... Done
Repairing Microsoft.Android.Runtime.31.android-x86.32.0.448-x64.msi ..... Done
Repairing Microsoft.Android.Runtime.31.android-x64.32.0.448.msi ..... Done
Repairing Microsoft.Android.Templates.32.0.448-x64.msi .... Done
Repairing Microsoft.Mono.android-arm.6.0.9-x64.msi ....... Done
Downloading Microsoft.NETCore.App.Runtime.Mono.android-arm64.Msi.x64 (6.0.9)
Repairing Microsoft.Mono.android-arm64.6.0.9-x64.msi ........ Done
Repairing Microsoft.Mono.android-x64.6.0.9.msi ........ Done
Repairing Microsoft.Mono.android-x86.6.0.9-x64.msi ....... Done
Repairing Microsoft.AOT.win-x64.Cross.android-x86.6.0.9.msi ..... Done
Repairing Microsoft.AOT.win-x64.Cross.android-x64.6.0.9.msi ..... Done
Repairing Microsoft.AOT.win-x64.Cross.android-arm.6.0.9.msi ..... Done
Repairing Microsoft.AOT.win-x64.Cross.android-arm64.6.0.9.msi ..... Done
Downloading Microsoft.Maui.Core.Ref.ios.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Core.Ref.ios.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Core.Runtime.ios.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Core.Runtime.ios.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Controls.Ref.ios.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Controls.Ref.ios.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Controls.Runtime.ios.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Controls.Runtime.ios.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Essentials.Ref.ios.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Essentials.Ref.ios.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Essentials.Runtime.ios.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Essentials.Runtime.ios.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Core.Ref.tizen.Msi.x64 (6.0.536)
Installing Microsoft.Maui.Core.Ref.tizen.6.0.536.0-x64.msi ..... Done
Downloading Microsoft.Maui.Core.Runtime.tizen.Msi.x64 (6.0.536)
Installing Microsoft.Maui.Core.Runtime.tizen.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Controls.Ref.tizen.Msi.x64 (6.0.536)
Installing Microsoft.Maui.Controls.Ref.tizen.6.0.536.0-x64.msi ..... Done
Downloading Microsoft.Maui.Controls.Runtime.tizen.Msi.x64 (6.0.536)
Installing Microsoft.Maui.Controls.Runtime.tizen.6.0.536.0-x64.msi ..... Done
Downloading Microsoft.Maui.Essentials.Ref.tizen.Msi.x64 (6.0.536)
Installing Microsoft.Maui.Essentials.Ref.tizen.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Essentials.Runtime.tizen.Msi.x64 (6.0.536)
Installing Microsoft.Maui.Essentials.Runtime.tizen.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Core.Ref.maccatalyst.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Core.Ref.maccatalyst.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Core.Runtime.maccatalyst.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Core.Runtime.maccatalyst.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Controls.Ref.maccatalyst.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Controls.Ref.maccatalyst.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Controls.Runtime.maccatalyst.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Controls.Runtime.maccatalyst.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Essentials.Ref.maccatalyst.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Essentials.Ref.maccatalyst.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Essentials.Runtime.maccatalyst.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Essentials.Runtime.maccatalyst.6.0.536.0-x64.msi .... Done
Downloading Microsoft.MacCatalyst.Sdk.Msi.x64 (15.4.447)
Installing Microsoft.MacCatalyst.Sdk.15.4.447.447-x64.msi ..... Done
Downloading Microsoft.MacCatalyst.Ref.Msi.x64 (15.4.447)
Installing Microsoft.MacCatalyst.Ref.15.4.447.447-x64.msi ..... Done
Downloading Microsoft.MacCatalyst.Runtime.maccatalyst-arm64.Msi.x64 (15.4.447)
Installing Microsoft.MacCatalyst.Runtime-arm64.15.4.447.447-x64.msi ..... Done
Downloading Microsoft.MacCatalyst.Runtime.maccatalyst-x64.Msi.x64 (15.4.447)
Installing Microsoft.MacCatalyst.Runtime-x64.15.4.447.447.msi ...... Done
Downloading Microsoft.MacCatalyst.Templates.Msi.x64 (15.4.447)
Installing Microsoft.MacCatalyst.Templates.15.4.447.447-x64.msi .... Done
Repairing Microsoft.Mono.maccatalyst-arm64.6.0.9-x64.msi ........ Done
Repairing Microsoft.Mono.maccatalyst-x64.6.0.9.msi ........ Done
Downloading Microsoft.Maui.Core.Ref.win.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Core.Ref.win.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Core.Runtime.win.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Core.Runtime.win.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Controls.Ref.win.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Controls.Ref.win.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Controls.Runtime.win.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Controls.Runtime.win.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Essentials.Ref.win.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Essentials.Ref.win.6.0.536.0-x64.msi .... Done
Downloading Microsoft.Maui.Essentials.Runtime.win.Msi.x64 (6.0.536)
Repairing Microsoft.Maui.Essentials.Runtime.win.6.0.536.0-x64.msi .... Done
Repairing Microsoft.Maui.Graphics.Win2D.6.0.403-x64.msi .... Done
Removing Microsoft.Maui.Controls.Ref.tizen.6.0.486.0-x64.msi ..... Done
Removing Microsoft.Maui.Controls.Runtime.tizen.6.0.486.0-x64.msi .... Done
Removing Microsoft.Maui.Core.Ref.tizen.6.0.486.0-x64.msi .... Done
Removing Microsoft.Maui.Core.Runtime.tizen.6.0.486.0-x64.msi .... Done
Removing Microsoft.Maui.Essentials.Ref.tizen.6.0.486.0-x64.msi .... Done
Removing Microsoft.Maui.Essentials.Runtime.tizen.6.0.486.0-x64.msi .... Done

Successfully repaired workloads: ios maui

To Reproduce

I'm not sure how to repro this -- perhaps it's a problem with migrating from older VS/dotnet installs.

Exceptions (if any)

When I run dotnet workload list, I got what I suspect is the same error but with more details:

PS R:\foo> dotnet workload list

Installed Workload Ids      Manifest Version      Installation Source
--------------------------------------------------------------------------------
ios                         15.4.447/6.0.400      SDK 6.0.400, VS 17.3.32922.545
maui                        6.0.536/6.0.400       SDK 6.0.400
maui-android                6.0.536/6.0.400       VS 17.3.32922.545
android                     32.0.448/6.0.400      VS 17.3.32922.545
maui-windows                6.0.536/6.0.400       VS 17.3.32922.545
maui-maccatalyst            6.0.536/6.0.400       VS 17.3.32922.545
maccatalyst                 15.4.447/6.0.400      VS 17.3.32922.545
maui-ios                    6.0.536/6.0.400       VS 17.3.32922.545

Use `dotnet workload search` to find additional workloads to install.

Unhandled exception: System.Collections.Generic.KeyNotFoundException: The given key 'Microsoft.iOS.Sdk' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadResolver.<>c__DisplayClass30_0.<GetUpdatedWorkloads>b__2(WorkloadPackId p)
   at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
   at Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadResolver.GetUpdatedWorkloads(WorkloadResolver advertisingManifestResolver, IEnumerable`1 installedWorkloads)+MoveNext()
   at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)
   at Microsoft.DotNet.Workloads.Workload.List.WorkloadListCommand.Execute()
   at Microsoft.DotNet.Cli.WorkloadListCommandParser.<>c.<ConstructCommand>b__6_0(ParseResult parseResult)
   at Microsoft.DotNet.Cli.ParseResultCommandHandler.Invoke(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass12_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__18_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseParseDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.CommandLineBuilderExtensions.<>c__DisplayClass8_0.<<UseExceptionHandler>b__0>d.MoveNext()

Further technical details

My global.json
{
  "sdk": {
    "version": "6.0.300",
    "rollForward": "latestFeature"
  }
}
My "dotnet --info"
PS R:\foo> dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.401
 Commit:    0906eae6f8

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19044
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.401\

Host:
  Version:      7.0.0-rc.1.22426.10
  Architecture: x64
  Commit:       06aceb7015

.NET SDKs installed:
  2.1.526 [C:\Program Files\dotnet\sdk]
  2.1.818 [C:\Program Files\dotnet\sdk]
  3.1.423 [C:\Program Files\dotnet\sdk]
  5.0.412 [C:\Program Files\dotnet\sdk]
  6.0.401 [C:\Program Files\dotnet\sdk]
  7.0.100-rc.1.22431.12 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.29 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.0-rc.1.22427.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.29 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.24 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.27 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.29 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-rc.2.20475.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.0-rc.1.22426.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.21 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.24 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.27 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.29 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.0-rc.2.20475.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.0-rc.1.22427.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  R:\foo\global.json

mstefarov avatar Sep 27 '22 20:09 mstefarov

Same issue here. Ver. 17.3.5 and 17.4.0 Preview 2.1. Is there a workaround? I can't develop any further now. Missing workload for specified target framework. Tizen is already deactivated in the project file. Error remains the same. Sorry if this is the wrong place to ask, but I haven't found anything else. Thank you.

AsPaper avatar Sep 28 '22 10:09 AsPaper

@mstefarov : I had the same issue. I have removed all non-maui workloads (e.g sudo dotnet workload uninstall maccatalyst) and just kept the maui ones. Now I can at least build my apps again in the VS Mac Preview.

Inux avatar Sep 28 '22 11:09 Inux

Can you share the results from dotnet --info and can you share the contents of the program files\dotnet\sdk-manifests folder (zip up the folder so we can take a look at the contents)?

marcpopMSFT avatar Sep 28 '22 21:09 marcpopMSFT

You can find the output of dotnet --info at the bottom of the issue, in a collapsed block ^

Here is a copy of the manifests folder: sdk-manifests.zip

mstefarov avatar Sep 28 '22 22:09 mstefarov

Same issue here after updating VS2022 from 17.3 to latest 17.3.5. Like @AsPaper now I can't develop any further. Hoping someone will give a solution ASAP.

radiolondra avatar Sep 29 '22 12:09 radiolondra

I hoped running dotnet workload repair would do the trick; it didn't.

I was able to successfully run dotnet workload uninstall ios, after which I ran dotnet workload restore which finally completed.

DonovanAGBR avatar Sep 30 '22 16:09 DonovanAGBR

Super. Thank you very much. That worked for me as well. I still had the same error message when creating the project, but after restarting visual Studio it worked. You made my day!

AsPaper avatar Sep 30 '22 17:09 AsPaper

Can folks still hitting this run the https://aka.ms/vscollect and provide us the logs? From looking at the code and the manifests provided above (thanks for that), we have a theory. Between August and September releases, we changed the 6.0 workload pack names to include a .net6 text so we could differentiate packs between net6 and net 7. From the manifests provided, the customer still has the August manifests even though they updated to 17.3.5 which should have included the newer manifests.

When you run workload commands, we check to see if there are updates but the pack names changes and that's that exception. @dsplaisted is that exception blocking cause it feels like we need to harden the code for this?

The solution is to get the workload manifests updated to the newer version. Maybe try dotnet workload install ios or maybe clear out the advertising manifest location under %temp% before trying that operation. We're still working on getting a repro now that we have a theory for why this works. Dononvan's solution may work here because it gets you into a state with the correct newer manifest files.

marcpopMSFT avatar Sep 30 '22 18:09 marcpopMSFT

Same issue here. @marcpopMSFT I ran Collect.exe but the log is 52MB. Should I just attach it here?

matt-goldman avatar Oct 02 '22 03:10 matt-goldman

I hoped running dotnet workload repair would do the trick; it didn't.

I was able to successfully run dotnet workload uninstall ios, after which I ran dotnet workload restore which finally completed.

Thanks, this mostly worked for me too. I had to uninstall some other workloads first too, but running restore let me know each time.

matt-goldman avatar Oct 02 '22 03:10 matt-goldman

currently it seems that workloads are totally broken and you cannot install any workload anymore. i cant install workload android ios or any other anymore...

workload search only results the following: image

if i understood correct this should list all downloadable workloads :(

tisis2 avatar Oct 03 '22 07:10 tisis2

@tisis2 your issue is probably different. Something is off in the workload manifests you have in the dotnet/sdk-manifests directory. Do you have Visual Studio installed or just the SDK? Which versions of each do you have installed?

marcpopMSFT avatar Oct 03 '22 20:10 marcpopMSFT

@matt-goldman thanks for the logs in email. Someone on the team is looking through them. We also have some folks trying to set up a repro of the situation. Our best guess is you have to have 17.3 + 17.4 + have installed workloads in 17.3 prior to updating either to the latest version. That would leave older packs installed on the machine from the initial install but the new installs should bring in later manifests and later advertising manifests.

The next thing to check is to have someone zip up the contents of their advertising manifest folder in the %temp%\dotnet-sdk-advertising-temp. Basically, from code there are different packs+manifests installed into the SDK than the versions we pre-download into the advertising temp location to check for updates.

marcpopMSFT avatar Oct 03 '22 20:10 marcpopMSFT

I think the advertising manifest folder we're probably interested in is %userprofile%\.dotnet\sdk-advertising.

dsplaisted avatar Oct 03 '22 20:10 dsplaisted

Here's the contents of my sdk-advertising folder. I have however managed to get around this problem by uninstalling the latest VS preview, uninstalling the ios and maccatalyst workloads, installing the latest stable VS 2022 and running dotnet workload restore. So in that case I'm not sure whether these are still of use to you, although I do note .NET 7 rc1 is in there. Hope this helps. https://1drv.ms/u/s!Ahqfqmc_Bc3KlvVQZHo_QZ5IMqEhfQ?e=DpGLBg

matt-goldman avatar Oct 03 '22 20:10 matt-goldman

@tisis2 your issue is probably different. Something is off in the workload manifests you have in the dotnet/sdk-manifests directory. Do you have Visual Studio installed or just the SDK? Which versions of each do you have installed?

@marcpopMSFT i had the issue like it was described before. i tried out to work around it... and finally i totally uninstalled all the SDKs and VS i had... after that i reinstalled VS 17.5. Enterprise. then i was not able to rebuild my maui project, my uno project nor my avalonia (i am currently evaluating... )

as you said, yes the manifests were missing but i expected they should either be installed or be fetched when executing the workload commands... i first tried rc1 of net 7 and the workloads were there but i got other build problems with it so i rolled back to net 6 and went to nuget.org looked for the manifest packages downloaded and extracted them by myself and placed them there where they were placed for net 7 and it worked again. still have some issues that uno builds only on commandline and not in VS anymore but that might be another issue no idea.

tisis2 avatar Oct 04 '22 05:10 tisis2

@matt-goldman I had exactly the same issue as in @mstefarov post. Copied your sdk.manfests folder from your link and pasted into mine. Issue has gone and now able to build maui apps in VS2022 17.3.5.

parko65 avatar Oct 04 '22 10:10 parko65

i tried it now a second time and uninstalled all sdks and did a new install of sdk 6.0.401. after that install only "microsoft.net.workload.emscripten" and "microsoft.net.workload.mono.toolchain" is in the manifests folder 6.0.300...

after the install of the dotnet sdk i installed VS 17.3.5 with the maui, desktop and web workloads selected. this created the 6.0.400 folder in the manifests folder that includes android, ios, maccatalyst, macos and tvos.

between uninstall and install i restarted my pc, what is different from the first time i tried to dix the issue and now it seems that workloads work again

tisis2 avatar Oct 04 '22 12:10 tisis2

First do :

dotnet workload list

Then for each workload do:

dotnet workload uninstall <name of the workload>

And finally:

dotnet workload install maui-ios maui-android

Thanks Microsoft

Syed-RI avatar Oct 04 '22 12:10 Syed-RI

adding reference to a similar issue #27587

suryapratap avatar Oct 05 '22 10:10 suryapratap

I've uninstalled VSPreview, uninstalled all workloads, repaired VS17.3, and reinstalled workloads. That solved my problem for a while.

I no longer have the preview installed, but after updating VS to 17.3.6 this problem came back. Most dotnet workload commands are printing KeyNotFoundException exceptions again, and I am unable to build for iOS again. I guess it's time to reinstall everything again.

mstefarov avatar Oct 12 '22 21:10 mstefarov

Repaired VS again. dotnet workload no longer throws errors, but I am still unable to build ios/maccatalyst projects 🤷

> dotnet workload list

Installed Workload Ids      Manifest Version      Installation Source
---------------------------------------------------------------------
maui-windows                6.0.541/6.0.400       VS 17.3.32929.385
maui-maccatalyst            6.0.541/6.0.400       VS 17.3.32929.385
maccatalyst                 15.4.447/6.0.400      VS 17.3.32929.385
maui-ios                    6.0.541/6.0.400       VS 17.3.32929.385
ios                         15.4.447/6.0.400      VS 17.3.32929.385
maui-android                6.0.541/6.0.400       VS 17.3.32929.385
android                     32.0.476/6.0.400      VS 17.3.32929.385
5>------ Build started: Project: MyProjectGoesHere (MyProjectGoesHere\MyProjectGoesHere), Configuration: Debug Any CPU ------
5>C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To build this project, the following workloads must be installed: ios
5>C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To install these workloads, run the following command: dotnet workload restore
5>C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To build this project, the following workloads must be installed: maccatalyst
5>C:\Program Files\dotnet\sdk\6.0.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To install these workloads, run the following command: dotnet workload restore

Running dotnet workload repair tells me that there is nothing to repair:

> dotnet workload repair

No workloads are installed, nothing to repair. Run `dotnet workload search` to find workloads to install.

mstefarov avatar Oct 12 '22 23:10 mstefarov

@mstefarov dotnet workload repair didnt work for me. i had to explicitly remove all workloads and then restore them

SimonCropp avatar Oct 13 '22 01:10 SimonCropp

Repair just reruns the msis for already installed workloads and so shouldn't be needed in this case. The problem here is that an older set of packs is installed compared with the versions found in the advertising manifests to install next and there was a breaking name change between the two and the SDK logic didn't handle that correctly. A fix is going in for this for the 7.0.100 release but I'm not sure how best to workaround this other than trying to uninstall all workloads.

@dsplaisted any ideas on better workarounds? Can they delete the advertising manifests from %temp%\Temp\dotnet-sdk-advertising-temp and then use a rollback file to force an update perhaps?

marcpopMSFT avatar Oct 14 '22 18:10 marcpopMSFT

https://github.com/dotnet/sdk/issues/27587#issuecomment-1279760064 This saved me. Download a dotnet sdk in zip format. Run inner dotnet workload update . Copy inner sdk-manifests to global dotnet folder(C:\Program Files\dotnet) run global dotnet workload update

yzbai avatar Oct 18 '22 05:10 yzbai

This will be fixed in the GA release (via https://github.com/dotnet/sdk/pull/28327)

dsplaisted avatar Oct 20 '22 17:10 dsplaisted

@dsplaisted thanks

SimonCropp avatar Oct 20 '22 23:10 SimonCropp