是否可以使用 Azure Devops Build Pipelines 和 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
任务,但并不总是很好。编辑:我应该补充一点,目前 Build 完全失败,因为:
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.
最佳答案
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'
关于.net-core - Azure Devops 管道 - 使用 DotNetCoreCLI@2 指定目标框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52628444/