是否可以使用Azure Devops生成管道和DotNetCoreCLI @ 2任务为ClassLibrary项目指定目标框架?还是我们必须恢复使用脚本并手动调用dotnet publish
命令?
我的管道YAML中的代码段
variables:
buildConfiguration: 'Debug'
steps:
- task: DotNetCoreCLI@2
inputs:
command: 'publish'
publishWebProjects: false # Required when command == Publish
projects: 'TestProject/Test/Test.csproj'
configuration: '$(BuildConfiguration)'
从我的.csproj:
<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;net45</TargetFrameworks>
</PropertyGroup>
我正在使用here文档来完成DotNetCoreCLI@2
任务,但这并不总是很好。
编辑:在构建完全失败的那一刻,我应该补充一点,因为:
The 'Publish' target is not supported without specifying a target framework.
The current project targets multiple frameworks, please specify the framework
for the published application.
答案 0 :(得分:1)
可以使用DotNetCoreCLI@2
属性扩展arguments
任务,您可以在该属性上指定框架(以及构建配置):
steps:
- task: DotNetCoreCLI@2
inputs:
command: 'publish'
publishWebProjects: false # Required when command == Publish
projects: 'TestProject/Test/Test.csproj'
arguments: '--configuration $(BuildConfiguration) --framework netcoreapp2.1'