question

osnipezzini avatar image
0 Votes"
osnipezzini asked AmyPeng1-MSFT edited

Build NET MAUI (Windows) on Azure Pipelines

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    


dotnet-maui
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Could you build your MAUI application with Visual Studio using your local machine without using Azure pipeline?

If it builds it successfully, then the issue may be related to the Azure Pipelines, you can open an issue in the Developer Community’s Azure DevOps forum: https://developercommunity.visualstudio.com/report?space=21&entry=problem.

Based on your error, I find a similar thread, using dotnet build to build a .NET MAUI app for Windows doesn't work with the current previews of .NET MAUI.

If it does not work in your local machine as well, please share more information about your error message or log.

Besides, please make sure you have included 'net6.0-windows10.0.19041' in the TargetFrameworks for your project.

<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
             <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net6.0-windows10.0.19041</TargetFrameworks>



0 Votes 0 ·

0 Answers