Estoy tratando de compilar un proyecto en .NET 5.0 mediante la compilación de canalización de Azure DevOps y recibo este error
2020-11-14T01:59:45.8238544Z [command]"C:\Program Files\dotnet\dotnet.exe" build D:\a\1\s\XXX.csproj "-dl:CentralLogger,\"D:\a\_tasks\DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b\2.178.0\dotnet-build-helpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll\"*ForwardingLogger,\"D:\a\_tasks\DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b\2.178.0\dotnet-build-helpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll\"" 2020-11-14T01:59:46.1472016Z Microsoft (R) Build Engine version 16.7.0+7fb82e5b2 for .NET 2020-11-14T01:59:46.1473316Z Copyright (C) Microsoft Corporation. All rights reserved. 2020-11-14T01:59:46.1473902Z 2020-11-14T01:59:46.6006398Z Determining projects to restore... 2020-11-14T01:59:47.2059773Z Restored D:\a\1\s\XXX.csproj (in 234 ms). 2020-11-14T01:59:47.2119638Z 1 of 2 projects are up-to-date for restore. 2020-11-14T01:59:47.3209350Z ##[error]C:\Program Files\dotnet\sdk\3.1.403\Microsoft.Common.CurrentVersion.targets(1177,5): Error MSB3644: The reference assemblies for .NETFramework,Version=v5.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks 2020-11-14T01:59:47.3261839ZC:\Program Files\dotnet\sdk\3.1.403\Microsoft.Common.CurrentVersion.targets(1177,5): error MSB3644: The reference assemblies for .NETFramework,Version=v5.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [D:\a\1\s\XXX.csproj] 2020-11-14T01:59:47.3270768Z 2020-11-14T01:59:47.3274231Z Build FAILED. 2020-11-14T01:59:47.3275925Z 2020-11-14T01:59:47.3277393ZC:\Program Files\dotnet\sdk\3.1.403\Microsoft.Common.CurrentVersion.targets(1177,5): error MSB3644: The reference assemblies for .NETFramework,Version=v5.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [D:\a\1\s\XXX.csproj] 2020-11-14T01:59:47.3279484Z 0 Warning(s) 2020-11-14T01:59:47.3279860Z 1 Error(s) 2020-11-14T01:59:47.3280170Z 2020-11-14T01:59:47.3280537Z Time Elapsed 00:00:01.09 2020-11-14T01:59:47.3624731Z ##[error]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1¿Alguien sabe si las canalizaciones de Azure DevOps son compatibles con la compilación de código .NET 5.0?
Sí, Azure DevOps Pipelines puede compilar aplicaciones net5.0 .
Si está construyendo con la tarea " .Net Core " ( DotNetCoreCLI en yaml), agregue la tarea " Usar .NET Core " ( UseDotNet en yaml) antes, con la versión correcta:
- task: UseDotNet@2 inputs: packageType: 'sdk' version: '5.0.x' - task: DotNetCoreCLI@2 displayName: 'dotnet build' inputs: command: 'build'es compatible.
Dado que está usando .Net 5, en lugar de usar la restauración de Nuget, intente usar Use .net core task y Dotnet core task con el comando de restauración.
- task: UseDotNet@2 displayName: 'Use .NET Core sdk 5.0.100' inputs: packageType: 'sdk' version: '5.0.100' includePreviewVersions: true - task: DotNetCoreCLI@2 displayName: 'dotnet restore' inputs: command: restore projects: '**/*.csproj' Se recomienda enfáticamente usar las tareas dotnet restore y dotnet build para proyectos destinados a .net core . Vea esta declaración de la tarea de Nuget :
También eche un vistazo a esta pregunta similar aquí: La canalización de Azure CI para Blazor .NET 5 no funciona
Necesitaba usar ambas versiones del marco para construir mi función en .net 5
pasos:
- task: UseDotNet@2 inputs: version: '5.0.x' packageType: sdk includePreviewVersions: false - task: UseDotNet@2 inputs: version: '3.1.x' packageType: sdk includePreviewVersions: false