Build NET MAUI (Windows) on Azure Pipelines
Osni Pezzini Junior
1
Reputation point
I'm trying to build a multi-platform library on Azure Pipelines, but when try to compile NET MAUI for Windows give me a error.
[error]C:\hostedtoolcache\windows\dotnet\sdk\6.0.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(267,5): Error NETSDK1005: Assets file 'D:\a\1\s\src\SOCore\obj\project.assets.json' doesn't have a target for 'net6.0-windows10.0.19041'. Ensure that restore has run and that you have included 'net6.0-windows10.0.19041' in the TargetFrameworks for your project.
variables:
CurrentSemanticVersionBase: '0.0.1'
PreviewNumber: $[counter(variables['CurrentSemanticVersionBase'], 1001)]
CurrentSemanticVersion: '$(CurrentSemanticVersionBase)-preview$(PreviewNumber)'
NugetPackageVersion: '$(CurrentSemanticVersion)'
PathToSolution: 'src/SOTechLibraries.sln'
PathToSOCoreCsproj: 'src/SOCore/SOCore.csproj'
PathToCoreTestCsproj: 'src/SOCore.Tests/SOCore.Tests.csproj'
strategy:
matrix:
windows:
imageName: 'windows-latest'
pool:
vmImage: $(imageName)
steps:
- task: UseDotNet@2
displayName: 'Instalar SDK do NET 5'
inputs:
version: '5.0.x'
- task: UseDotNet@2
displayName: 'Instalar SDK do NET 6'
inputs:
version: '6.0.x'
- task: Bash@3
displayName: 'Baixar SDK do Windows'
inputs:
targetType: 'inline'
script: |
# Write your commands here
curl -LO "https://download.microsoft.com/download/4/d/2/4d2b7011-606a-467e-99b4-99550bf24ffc/windowssdk/winsdksetup.exe"
chmod 777 winsdksetup.exe
- task: PowerShell@2
displayName: 'Instalar SDK do Windows'
inputs:
targetType: 'inline'
script: 'Start-Process winsdksetup.exe -ArgumentList "/q" -Wait'
- task: CmdLine@2
displayName: 'Instalar carga de trabalho do .NET MAUI'
inputs:
script: 'dotnet workload install maui'
- task: CmdLine@2
displayName: 'Limpar cache do nuget' #https://github.com/actions/virtual-environments/issues/1090#issuecomment-748452120
inputs:
script: 'nuget locals all -clear'
- task: CmdLine@2
displayName: 'Restaurar pacotes nuget'
inputs:
script: 'dotnet restore $(PathToSOCoreCsproj)'
- task: CmdLine@2
displayName: 'Limpar solução'
inputs:
script: 'dotnet clean $(PathToSolution)'
# if this is a tagged build, then update the version number
- powershell: |
$buildSourceBranch = "$(Build.SourceBranch)"
$tagVersion = $buildSourceBranch.Substring($buildSourceBranch.LastIndexOf("/") + 1)
Write-Host("Branch = $buildSourceBranch, Version = $tagVersion");
Write-Host ("##vso[task.setvariable variable=NugetPackageVersion;]$tagVersion")
displayName: Alterar versão do NuGet para versão da TAG
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
- task: MSBuild@1
inputs:
solution: $(PathToSOCoreCsproj)
restoreNugetPackages: true