Ruina
Ruina

Reputation: 365

dotnet workload restore for MAUI fails with .NET 7

Fails to install workloads for MAUI for .NET 7 when running in azure dev ops. I was running the same pipeline in .NET 6 and it worked fine, but when I updated to .NET 7, it started failing to install the MAUI workload.

YAML

- task: UseDotNet@2
  displayName: 'Use .NET Core sdk 7.x'
  inputs:
    version: 7.x

- task: DotNetCoreCLI@2
  displayName: 'dotnet workload'
  inputs:
    command: custom
    custom: 'workload '
    arguments: 'install maui'

Logs

Installing pack Microsoft.Maui.Core.Ref.android version 7.0.0-rc.1.6430...
Workload installation failed. Rolling back installed packs...
Rolling back pack Microsoft.Maui.Core.Ref.android installation...
Workload installation failed: Unable to load the service index for source https://nuget.telerik.com/v3/index.json.
##[debug]Exit code 1 received from tool 'C:\hostedtoolcache\windows\dotnet\dotnet.exe'
##[debug]STDIO streams have closed for tool 'C:\hostedtoolcache\windows\dotnet\dotnet.exe'
##[error]Error: The process 'C:\hostedtoolcache\windows\dotnet\dotnet.exe' failed with exit code 1
##[debug]Processed: ##vso[task.issue type=error;]Error: The process 'C:\hostedtoolcache\windows\dotnet\dotnet.exe' failed with exit code 1
Info: Azure Pipelines hosted agents have been updated and now contain .Net 5.x SDK/Runtime along with the older .Net Core version which are currently lts. Unless you have locked down a SDK version for your project(s), 5.x SDK might be picked up which might have breaking behavior as compared to previous versions. You can learn more about the breaking changes here: https://docs.microsoft.com/en-us/dotnet/core/tools/ and https://docs.microsoft.com/en-us/dotnet/core/compatibility/ . To learn about more such changes and troubleshoot, refer here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting
##[debug]task result: Failed
##[error]Dotnet command failed with non-zero exit code on the following projects : 
##[debug]Processed: ##vso[task.issue type=error;]Dotnet command failed with non-zero exit code on the following projects : 
##[debug]Processed: ##vso[task.complete result=Failed;]Dotnet command failed with non-zero exit code on the following projects : 
Finishing: dotnet workload

Comments

Upvotes: 0

Views: 5475

Answers (2)

Ruina
Ruina

Reputation: 365

I was able to fix this by specifying the --source on the command. I think me having external nuget sources for private feeds was interfering with it selecting the correct workload version somehow.

- task: DotNetCoreCLI@2
  displayName: 'dotnet workload'
  inputs:
    command: custom
    custom: 'workload '
    arguments: 'install maui --source https://api.nuget.org/v3/index.json'

Upvotes: 5

Kevin Lu-MSFT
Kevin Lu-MSFT

Reputation: 35414

Installing pack Microsoft.Maui.Core.Ref.android version 7.0.0-rc.1.6430..

When you run the dotnet workload install maui, it will install maui according to the .net SDK version specified in global.json file firstly.

When you have a global.json file in your project, it will keep the version specified in the file even if you install the latest .NET 7 in the Pipeline.

To solve this issue, you can modify the global.json file and define the .net version(7.0.100).

For example:

{
  "sdk": {
    "allowPrerelease": true,
    "rollForward": "disable",
    "version": "7.0.100"
  }
}

You can disable the rollForward in global.json file. Then it will not automatically upgrade the dotnet version of the project.

When you run the pipeline with the global.json above, it will use the version: Microsoft.Maui.Core.Ref.android version 7.0.49. This is the latest version of Maui.

Result:

enter image description here

Upvotes: 1

Related Questions