yaml - 如何在 Build Yaml 中进行 dotnet 发布

标签 yaml azure-pipelines asp.net-core-2.1

如果需要在 .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,

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

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 文件)

关于yaml - 如何在 Build Yaml 中进行 dotnet 发布,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55438250/

相关文章:

api - 用于克隆资源的REST API设计

yaml - 在YAML中扩展数组?

azure-devops - 使用发布管道变量更新 web.config 值的推荐方法是什么?

java - 从 Yaml 文件加载 Java Builder 对象

用于在 YAML 中插入标记的 Java 框架

visual-studio - VSTS:如何在Visual Studio构建步骤为多个项目中处理FileSystem WebPublishMethod

azure - 使用 Azure Dev Ops Pipelines 的通用 git 连接时,是否可以通过 SSH key 克隆代码?

c# - 使用 Async Await 是否可以避免线程耗尽?

c# - 带有种子的添加迁移抛出 "no value provided"异常

unit-testing - 如何在用 [ApiController] 装饰的 Controller 中对模型验证进行单元测试?