Skip to content

Instantly share code, notes, and snippets.

@jonathanpeppers
Last active April 24, 2024 22:54
Show Gist options
  • Save jonathanpeppers/63beb491a9185ac06710261536cc35c9 to your computer and use it in GitHub Desktop.
Save jonathanpeppers/63beb491a9185ac06710261536cc35c9 to your computer and use it in GitHub Desktop.

.NET Workload Troubleshooting

To install the maui workload, you have two options:

  1. dotnet workload install commands
  2. Visual Studio on Windows can install .msi files for each workload pack. Note that the concept of a "Visual Studio workload" is different than a ".NET workload".

VS for Mac's installer and updater use dotnet workload install commands. It's considerably simpler to get a Mac machine to a clean state.

Mac

Since, .pkg files don't really have a way to "uninstall" the simplest way to get your machine in a clean state is to simply delete folders:

rm -r ~/.dotnet/
sudo rm -r /usr/local/share/dotnet/

After doing this, install the .NET SDK of your choice and run dotnet workload install maui for a clean install.

Windows

This is where things get... complicated.

The .NET SDK has two types of installers:

  • Microsoft .NET SDK 6.0.300 from Visual Studio
  • Microsoft .NET SDK 6.0.300 - standalone

Things also can get "weird" if you command-line dotnet workload install on top of packages installed by Visual Studio.

Here are steps to get to a clean state:

  1. If you ever used dotnet workload install, run dotnet workload uninstall maui.
  2. Uninstall any standalone .NET SDK installers from Control Panel. These are the ones that do not say "from Visual Studio".
  3. In every instance of Visual Studio, uninstall all Mobile/MAUI and .NET/Desktop "Visual Studio" workloads.

Next, let's check if there are additional .msi's hanging around:

reg query HKLM\SOFTWARE\Microsoft\Windows\currentversion\uninstall\ -s -f manifest

If you get results after uninstalling, like:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\currentversion\uninstall\{EEC1BB5F-3391-43C2-810E-42D78ADF3140}
    InstallSource    REG_SZ    C:\ProgramData\Microsoft\VisualStudio\Packages\Microsoft.MacCatalyst.Manifest-6.0.300,version=125.179.40883,chip=x64,productarch=neutral\
    DisplayName    REG_SZ    Microsoft.NET.Sdk.MacCatalyst.Manifest-6.0.300

Then you can grab the GUID and uninstall this package via:

msiexec /x {EEC1BB5F-3391-43C2-810E-42D78ADF3140} /q IGNOREDEPENDENCIES=ALL

After the reg query command returns no results, and all .NET 6+ SDKs are uninstalled, you might consider deleting:

  • C:\Program Files\dotnet\sdk-manifests
  • C:\Program Files\dotnet\metadata
  • C:\Program Files\dotnet\packs
  • C:\Program Files\dotnet\library-packs
  • C:\Program Files\dotnet\template-packs
  • C:\Program Files\dotnet\sdk\6.* or 7, etc.
  • C:\Program Files\dotnet\host\fxr\6.* or 7, etc.
@joshball
Copy link

joshball commented Apr 9, 2024

Here is the PowerShell script to query and uninstall them all.

$output = & reg query HKLM\SOFTWARE\Microsoft\Windows\currentversion\uninstall\ -s -f manifest
$guids = $output -match '{.*}' | ForEach-Object { $_.Trim() }

foreach ($guid in $guids) {
  Write-Host "Uninstalling $guid"
  Start-Process -Wait -FilePath "msiexec" -ArgumentList "/x $guid /passive IGNOREDEPENDENCIES=ALL"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment