.NET Core 3.1 应用程序不再构建在 Azure 管道上 (.NET 5)

.NET Core 3.1 application not building on Azure pipeline anymore (.NET 5)

直到最近,我们的 .Net Core 3.1 应用程序都可以在 Azure 管道上正常构建和发布。但是在过去的几天里,构建管道开始失败并出现错误:

##[error]C:\Program Files\dotnet\sdk.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(241,5): 
Error NETSDK1005: Assets file 'D:\a\s\ProjectFolder\src\Project\obj\project.assets.json' doesn't have a target for 'netcoreapp3.1'. 
Ensure that restore has run and that you have included 'netcoreapp3.1' in the TargetFrameworks for your project.
(ResolvePackageAssets target) -> 
  C:\Program Files\dotnet\sdk.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(241,5): 
error NETSDK1005: Assets file 'D:\a\s\ProjectFolder\src\Project\obj\project.assets.json' doesn't have a target for 'netcoreapp3.1'. 
Ensure that restore has run and that you have included 'netcoreapp3.1' in the TargetFrameworks for your project. [D:\a\s\ProjectFolder\src\Project\Project.csproj]

针对失败的解决方案构建步骤,构建管道的设置如下。

有什么想法可以用最少的更改来解决这个问题吗?

.NET Core 3.1 application not building on Azure pipeline anymore (.NET 5)

请尝试通过任务NuGet tool installer

nuget.exe更新为5.8.0

您可以查看 this thread 了解更多详情。

本地构建代理遇到同样的问题

error NETSDK1005: Assets file 'project.assets.json' ....

更新NuGet.exe至5.8.0或以上版本

并清除 NuGet 缓存:

dotnet nuget locals all --clear

Download Nuget

找到here