Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET MAUI workload restore error Failed to run MSBuild Target _GetRequiredWorkloads

**When I create and Build a .NET MAUI application (.NET 6), I get the following errors. How can I solve them? Visual Studio 2022 version 17.4.2 Is this problem related to my country's internet? (From Iran) Is the problem with certain individual components that I have not installed? Errors

Build

By executing the "dotnet workload restore" command:

__________________________________________________
Project "S:\Projects\MauiApp1\MauiApp1\MauiApp1.csproj" (_GetRequiredWorkloads target(s)):

__________________________________________________
Project "S:\Projects\MauiApp1\MauiApp1\MauiApp1.csproj" is building "S:\Projects\MauiApp1\MauiApp1\MauiApp1.csproj" (_GetRequiredWorkloads target(s)):

C:\Program Files\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(1220,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\16.1.1481\targets\Xamarin.Shared.Sdk.MultiTarget.targets" was not found. Confirm that the expression in the Import declaration ";..\16.1.1481\targets\Xamarin.Shared.Sdk.MultiTarget.targets;C:\Program Files\dotnet\packs\Microsoft.Maui.Sdk\6.0.547\Sdk\Microsoft.Maui.Sdk.After.targets;C:\Program Files\dotnet\packs\Microsoft.Maui.Sdk\6.0.547\Sdk\Microsoft.Maui.Core.Sdk.After.targets;C:\Program Files\dotnet\packs\Microsoft.Maui.Sdk\6.0.547\Sdk\Microsoft.Maui.Controls.Sdk.After.targets;C:\Program Files\dotnet\packs\Microsoft.Maui.Resizetizer.Sdk\7.0.49\Sdk\../targets/Microsoft.Maui.Resizetizer.targets" is correct, and that the file exists on disk.
Done building project "MauiApp1.csproj" -- FAILED.
__________________________________________________
Project "S:\Projects\MauiApp1\MauiApp1\MauiApp1.csproj" is building "S:\Projects\MauiApp1\MauiApp1\MauiApp1.csproj" (_GetRequiredWorkloads target(s)):

C:\Program Files\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(1220,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\16.1.1481\targets\Xamarin.Shared.Sdk.MultiTarget.targets" was not found. Confirm that the expression in the Import declaration ";..\16.1.1481\targets\Xamarin.Shared.Sdk.MultiTarget.targets;C:\Program Files\dotnet\packs\Microsoft.Maui.Sdk\6.0.547\Sdk\Microsoft.Maui.Sdk.After.targets;C:\Program Files\dotnet\packs\Microsoft.Maui.Sdk\6.0.547\Sdk\Microsoft.Maui.Core.Sdk.After.targets;C:\Program Files\dotnet\packs\Microsoft.Maui.Sdk\6.0.547\Sdk\Microsoft.Maui.Controls.Sdk.After.targets;C:\Program Files\dotnet\packs\Microsoft.Maui.Resizetizer.Sdk\7.0.49\Sdk\../targets/Microsoft.Maui.Resizetizer.targets" is correct, and that the file exists on disk.
Done building project "MauiApp1.csproj" -- FAILED.
dotnet : Failed to restore workload for project S:\Projects\MauiApp1\MauiApp1\MauiApp1.csproj: Failed to run MSBuild Target _GetRequiredWorkloads.
At line:1 char:1
+ dotnet workload restore
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Failed to resto...uiredWorkloads.:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

By executing the "Dotnet workload install wasm-tools" command:

The machine has a pending reboot. Installation will continue, but you may need to restart.
Downloading microsoft.net.sdk.maui.manifest-7.0.100.msi.x64 (7.0.52)
Installing Microsoft.NET.Sdk.Maui.Manifest-7.0.100.7.0.52-x64.msi ............. Done
Downloading microsoft.net.sdk.tvos.manifest-7.0.100.msi.x64 (16.1.1481)
Installing Microsoft.NET.Sdk.tvOS.Manifest-7.0.100.16.1.1481-x64.msi ....... Done
Downloading Microsoft.NET.Runtime.WebAssembly.Sdk.Msi.x64 (7.0.1)
Installing Microsoft.WebAssembly.Sdk.7.0.1-x64.msi ....... Done
Downloading Microsoft.NETCore.App.Runtime.Mono.browser-wasm.Msi.x64 (7.0.1)
Installing Microsoft.Mono.browser-wasm.7.0.1-x64.msi ............ Done
Downloading Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.browser-wasm.Msi.x64 (7.0.1)
Installing Microsoft.AOT.win-x64.Cross.browser-wasm.7.0.1-x64.msi ...... Done
Downloading Microsoft.NET.Runtime.MonoAOTCompiler.Task.Msi.x64 (7.0.1)
Installing Microsoft.MonoAOTCompiler.Task.7.0.1-x64.msi ....... Done
Downloading Microsoft.NET.Runtime.MonoTargets.Sdk.Msi.x64 (7.0.1)
Installing Microsoft.MonoTargets.Sdk.7.0.1-x64.msi ...... Done
Downloading Microsoft.NET.Runtime.Emscripten.3.1.12.Node.win-x64.Msi.x64 (7.0.1)
Installing Microsoft.Emscripten.3.1.12.Node.win-x64.7.0.1-x64.msi ......... Done
Downloading Microsoft.NET.Runtime.Emscripten.3.1.12.Python.win-x64.Msi.x64 (7.0.1)
Installing Microsoft.Emscripten.3.1.12.Python.win-x64.7.0.1-x64.msi ...................... Done
Downloading Microsoft.NET.Runtime.Emscripten.3.1.12.Cache.win-x64.Msi.x64 (7.0.1)
Installing Microsoft.Emscripten.3.1.12.Cache.win-x64.7.0.1-x64.msi ....................... Done
Downloading Microsoft.NET.Runtime.Emscripten.3.1.12.Sdk.win-x64.Msi.x64 (7.0.1)
Workload installation failed. Rolling back installed packs...
Removing Microsoft.Emscripten.3.1.12.Cache.win-x64.7.0.1-x64.msi ............................... Done
Removing Microsoft.Emscripten.3.1.12.Python.win-x64.7.0.1-x64.msi ............................ Done
Removing Microsoft.Emscripten.3.1.12.Node.win-x64.7.0.1-x64.msi .... Done
Removing Microsoft.MonoTargets.Sdk.7.0.1-x64.msi ..... Done
Removing Microsoft.MonoAOTCompiler.Task.7.0.1-x64.msi ..... Done
Removing Microsoft.AOT.win-x64.Cross.browser-wasm.7.0.1-x64.msi ..... Done
Removing Microsoft.Mono.browser-wasm.7.0.1-x64.msi ......... Done
Removing Microsoft.WebAssembly.Sdk.7.0.1-x64.msi ..... Done
Downloading microsoft.net.sdk.tvos.manifest-7.0.100.msi.x64 (16.0.1478)
Downloading microsoft.net.sdk.maui.manifest-7.0.100.msi.x64 (7.0.49)
Dotnet : Workload installation failed: One or more errors occurred. (Downloading microsoft.net.runtime.emscripten.3.1.12.sdk.win-x64.msi.x64 version 7.0.1 failed)
At line:1 char:1
+ Dotnet workload install wasm-tools
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Workload instal...n 7.0.1 failed):String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

Picture

like image 942
P B Avatar asked Sep 17 '25 13:09

P B


1 Answers

I had the exact same errors with the "hello world", "click me" app that is the default. It worked for weeks then suddenly it would no longer compile. Got the same errors.

After a few weeks of looking, this finally resolved it for me:

In the Developer Command Prompt I ran:

dotnet workload install maui

(run this with sudo if you get not enough permissions error)

This ran for quite a while.

After it completed I exited out of visual studio, restarted, reloaded the solution, but it still failed. I gave it time to do all the stuff it seemed to be doing.

I exited out of visual studio more time, relaunched and I am now compiling. (I fear it will stop again at some point).

like image 61
user3009680 Avatar answered Sep 19 '25 05:09

user3009680