如何在 Build Yaml 中进行 dotnet 发布

SMP*_*MPH 2 yaml azure-pipelines asp.net-core-2.1

如果需要dotnet publish.Net Core 2.1. 提到无法弄清楚确切的方式。

它在下面说,yaml方式应该是什么

要使此任务起作用,您必须已使用 dotnet publish --output $(Build.ArtifactStagingDirectory) 命令将构建的输出发布到此目录。要在发布前将其他文件复制到此目录,

例如下面如何build.yaml在类应用程序中表示(API 解决方案)

dotnet publish ~/projects/app1/app1.csproj
Run Code Online (Sandbox Code Playgroud)

下面试过

- task: DotNetCoreCLI@2
      displayName: "Prepare Publish Files"
      inputs:
        command: publish
        projects: ""
        arguments: --output $(Build.ArtifactStagingDirectory)/src/xxx.EndToEnd.Integration.Tests/xxx.EndToEnd.Integration.Tests.csproj
Run Code Online (Sandbox Code Playgroud)

但是得到以下错误,实际上我的是 API 解决方案,我试图在其中发布 end2end 测试并在部署后运行它们。

##[error]No web project was found in the repository. Web projects are identified by presence of either a web.config file or wwwroot folder in the directory.
##[error]Project file(s) matching the specified pattern were not found.
Run Code Online (Sandbox Code Playgroud)

SMP*_*MPH 7

使用下面的YAML代码,我能够运行构建

- task: DotNetCoreCLI@2
  displayName: "dotnet e2e tests"
  inputs:
    command: publish
    publishWebProjects: false
    projects: '**/*.csproj'
    arguments: --output $(Build.ArtifactStagingDirectory)/src/xxx.EndToEnd.Integration.Tests
    zipAfterPublish: false
Run Code Online (Sandbox Code Playgroud)

解释:

publishWebProjects: false - 因为这是一个 API 解决方案。

简单的方法是在设计器向导中创建任务并在那里查看 YAML 文件(单独的选项卡以显示 yaml 文件)