Ric*_*d77 2 azure-devops asp.net-core azure-pipelines
我创建了一个简单的 ASP.NET CORE 6 Web API。然后我把它推到了Github上。当我尝试在Azure Devops中创建管道时,出现错误。
C:\Program Files\dotnet\sdk\5.0.403\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET
.TargetFrameworkInference.targets(141,5): error NETSDK1045: The current .NET SDK does not support
targeting .NET 6.0. Either target .NET 5.0 or lower, or use a version of the .NET SDK that supports
.NET 6.0.
Run Code Online (Sandbox Code Playgroud)
我刚刚下载了 VS 2022 社区版。我已经安装了 .Net SDK 6。这是我的 csproj 文件
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
我选择了 Azure devops 建议的内容,所以这是我的 yml 文件
# ASP.NET
# Build and test ASP.NET projects.
# Add steps that publish symbols, save build artifacts, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package
/p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true
/p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
Run Code Online (Sandbox Code Playgroud)
我已按照他的文档中的说明进行操作,但它不起作用。构建仍然像这样失败
[![在此处输入图像描述][2]][2]
感谢您的帮助
阅读这 2 个链接后,发现 Azure DevOps 的模板存在 2 个问题。
vmImage: 'windows-latest'
使用vmImage: 'windows-2022'
允许构建成功https://github.com/dotnet/core/issues/6907。我最终使用了经典模板,以便我可以更好地理解管道的工作原理。1) 使用 ubuntu-latest 或 windows-2022。2)添加SDK版本的步骤。
归档时间: |
|
查看次数: |
7551 次 |
最近记录: |