MAUI workload restoration fails for projects pinned to previous version via global.json
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 1.3k
- PR merge metrics
- PR metrics pending
Description
### Description
After installing .NET 10.0.1 alongside .NET 9.0.11, MAUI workload restoration fails for projects pinned to .NET 9.x via `global.json`. The workload resolver appears to be using .NET 10 SDK components even when the project explicitly targets .NET 9, preventing side-by-side installations of major .NET versions.
### Expected Behavior
The workload restore command should respect the SDK version specified in `global.json` and successfully restore MAUI workloads for .NET 9.x projects, even when .NET 10.x is installed on the system.
### Actual Behavior
The command fails with:
```text
Unhandled exception: SDK Resolver Failure: "The SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" failed while attempting to resolve the SDK "Microsoft.NET.SDK.WorkloadAutoImportPropsLocator". Exception: "System.IO.FileNotFoundException: Workload version 9.0.305, which was specified in /Users/[user]/source/MyProject/src/global.json, was not found. Run "dotnet workload restore" to install this workload version.
... (full stack in the "Relevant Log Output")
```
The error originates from `/usr/local/share/dotnet/sdk/10.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.props`, indicating the .NET 10 SDK is being used instead of the .NET 9 SDK specified in `global.json`.
### Steps to Reproduce
1. Upgrade to .NET 9.0.11 from 9.0.9
2. Install .NET SDK 10.0.1 (side-by-side installation)
3. Create or navigate to a MAUI project with `global.json` specifying SDK version 9.0.305
4. Run `dotnet workload restore` on the .NET 9 project
### Link to public reproduction project repository
_No response_
### Version with bug
10.0.10
### Is this a regression from previous behavior?
Not sure, did not test other versions
### Last version that worked well
9.0.110 SR11
### Affected platforms
iOS
### Affected platform versions
_No response_
### Did you find any workaround?
No. I even nuked all the things `dotnet` I could find on my machine (every version of the sdk, runtime, manifests, and workloads)
### Relevant log output
```shell
Unhandled exception: SDK Resolver Failure: "The SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" failed while attempting to resolve the SDK "Microsoft.NET.SDK.WorkloadAutoImportPropsLocator". Exception: "System.IO.FileNotFoundException: Workload version 9.0.305, which was specified in /Users/[user]/source/MyProject/src/global.json, was not found. Run "dotnet workload restore" to install this workload version. at Microsoft.NET.Sdk.WorkloadManifestReader.SdkDirectoryWorkloadManifestProvider.GetManifests() at Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadResolver.LoadManifestsFromProvider(IWorkloadManifestProvider manifestProvider) at Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadResolver.InitializeManifests() at Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadResolver.GetInstalledWorkloadPacksOfKind(WorkloadPackKind kind)+MoveNext() at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.CachingWorkloadResolver.Resolve(String sdkReferenceName, IWorkloadManifestProvider manifestProvider, IWorkloadResolver workloadResolver) at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.CachingWorkloadResolver.Resolve(String sdkReferenceName, String dotnetRootPath, String sdkVersion, String userProfileDir, String globalJsonPath) at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.WorkloadSdkResolver.Resolve(SdkReference sdkReference, SdkResolverContext resolverContext, SdkResultFactory factory) at Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.TryResolveSdkUsingSpecifiedResolvers(IReadOnlyList1 resolvers, Int32 submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, String solutionPath, String projectPath, Boolean interactive, Boolean isRunningInVisualStudio, SdkResult& sdkResult, IEnumerable1& errors, IEnumerable`1& warnings)"" /usr/local/share/dotnet/sdk/10.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.props
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.