1

根据此处的 MSDocs ,有一项任务是发布带有参数的 .NET Core。

dotnet publish --output $(Build.ArtifactStagingDirectory)

但是我有一个 .NET Framework 应用程序,而不是 .NET Core,这意味着我使用 MSBuild 任务而不是 dotnetcore 任务来构建 .NET。所以我查看了.NET Framework 页面,实际上没有关于发布 .NET Framework 应用程序的信息...

这是否意味着相同的 dotnetcore 任务适用/可用于 .NET Framework 应用程序?

steps:

- task: DotNetCoreCLI@2
  inputs:
    command: publish
    publishWebProjects: True
    arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
    zipAfterPublish: True

# this code takes all the files in $(Build.ArtifactStagingDirectory) and uploads them as an artifact of your build.
- task: PublishBuildArtifacts@1
  inputs:
    pathtoPublish: '$(Build.ArtifactStagingDirectory)' 
    artifactName: 'myWebsiteName'
4

1 回答 1

2

以下构建适用于 ubuntu 构建代理:

在此处输入图像描述

yaml 定义:

steps:

- task: NuGetToolInstaller@1    
  displayName: 'Use NuGet '    

- task: NuGetCommand@2    
  displayName: 'NuGet restore'    
  inputs:    
    restoreSolution: '<my_path>.sln'    

- task: MSBuild@1    
  displayName: 'Build solution <my_path>.sln'    
  inputs:    
    solution: '<my_path>.sln'    
    platform: '$(BuildPlatform)'    
    configuration: '$(BuildConfiguration)'    

- task: CopyFiles@2    
  displayName: 'Copy Files to: $(build.artifactstagingdirectory)'    
  inputs:    
    SourceFolder: '$(system.defaultworkingdirectory)'    
    Contents: '**/bin/**'    
    TargetFolder: '$(build.artifactstagingdirectory)'    
  condition: succeededOrFailed()
       
- task: PublishBuildArtifacts@1    
  displayName: 'Publish Artifact: drop'    
  inputs:    
    PathtoPublish: '$(build.artifactstagingdirectory)'    
  condition: succeededOrFailed()
于 2021-03-25T14:38:35.597 回答