如何在 Build Yaml 中进行 dotnet 发布

How to do dotnet publish in Build Yaml

如果需要在.Net Core 2.1中做dotnet publish测试项目,能否请您举例说明在build.yaml中指定的方式。参考 this 想不通。

下面说了,yaml的方式应该是什么

For this task to work, you must have already published the output of your build to this directory by using the dotnet publish --output $(Build.ArtifactStagingDirectory) command. To copy additional files to this directory before publishing,

作为示例,下面如何在 class 应用程序(API 解决方案)

中表示 build.yaml
dotnet publish ~/projects/app1/app1.csproj

试过以下

- 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

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

##[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.

使用下面的 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

说明:

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

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