Troubleshooting Azure DevOps Pipeline for .NET MAUI Blazor Hybrid App
Background_March7229 seeks help configuring an Azure DevOps pipeline for a .NET MAUI Blazor Hybrid app, describing errors encountered with runtime packages and pipeline tasks.
Troubleshooting Azure DevOps Pipeline for .NET MAUI Blazor Hybrid App
Author: Background_March7229
Scenario
The author attempts to build a simple .NET MAUI Blazor Hybrid project for Windows using Azure DevOps. The project is new with no modifications and is pushed directly to Azure DevOps.
Issue
During pipeline execution, the following error is encountered:
Unable to find package Microsoft.NETCore.App.Runtime.Mono.win-x64 with version
This occurs during the restore or publish phase when using .NET 9 and targeting win-x64
.
Pipeline Configuration (YAML)
trigger:
branches:
include:
- main
pool:
vmImage: 'windows-latest'
variables:
buildConfiguration: 'Release'
runtime: 'win-x64'
dotnetVersion: '9.0.101'
projectPath: 'MyApp/MyApp.csproj'
targetFramework: 'net9.0-windows10.0.19041.0'
outputDir: '$(Build.ArtifactStagingDirectory)/publish'
steps:
- task: UseDotNet@2
displayName: 'Install .NET 9.0.303 SDK'
inputs:
packageType: 'sdk'
version: '$(dotnetVersion)'
includePreviewVersions: true
- task: NuGetToolInstaller@1
- task: PowerShell@2
displayName: 'Install .NET MAUI Workload'
inputs:
targetType: 'inline'
script: |
dotnet workload install maui
- task: NuGetCommand@2
inputs:
restoreSolution: 'MyApp/MyApp.sln'
- task: DotNetCoreCLI@2
displayName: 'Publish MAUI App (.NET 9)'
inputs:
command: 'publish'
projects: '$(projectPath)'
arguments: >
-c $(buildConfiguration) -f $(targetFramework) -r $(runtime) --self-contained true -p:PublishSingleFile=true -p:WindowsPackageType=None -o $(outputDir)
Additional Feedback
- A community member suggests using
DotNetCoreCLI@2
with a restore command instead of NuGet restore for .NET projects. - The author reports receiving the same error after updating the pipeline to use
DotNetCoreCLI@2
for restore.
Observations
- The error suggests the .NET MAUI workload or required runtime packs for the targeted platform/version might be unavailable or missing from the feed used by the pipeline.
- Using preview SDKs with MAUI requires careful matching of workloads, SDK versions, and platform support.
- The build process may require additional setup to enable preview features or install specific runtime packs.
Suggestions for Similar Scenarios
- Ensure the specified
dotnetVersion
and the targeted framework are properly supported on the chosen build agent. - Confirm that the MAUI workload installs the correct version and all platform-specific packs.
- If using a preview SDK, add steps/flags to enable preview features or consider pinning to a stable release if available.
- Use
DotNetCoreCLI@2
for both restore and build/publish overNuGetCommand@2
to ensure best compatibility with modern .NET workloads. - Check that
Microsoft.NETCore.App.Runtime.Mono.win-x64
is available for the selected SDK/runtime versions or adjust the runtime/platform target as needed.
References
This post appeared first on “Reddit Azure DevOps”. Read the entire article here