Azure DevOps:解决方案中的一个项目的 CI 构建 [.Net Core]

发布于 2025-01-11 02:10:39 字数 660 浏览 0 评论 0原文

我在 .Net core 中有一个包含多个项目的解决方案。

  • src/Api/[ProjName].Api
  • [ProjName].FrontEnd

我们正在使用 Azure DevOPS 来使用 Azure 管道,并且我们需要为每个提到的项目拥有一个完整的单独的构建管道。我尝试过使用“路径过滤器”但无法完成此操作。我的管道从整个解决方案中创建了一个下降点。 已查看但未找到解决方案。

有人可以帮忙吗?

源代码路径

Azure DevOPS CI 管道

I have a solution in .Net core containing multiple projects.

  • src/Api/[ProjName].Api
  • [ProjName].FrontEnd

We are using the Azure pipelines using Azure DevOPS and we need to have a complete separate build pipelines for each of the mentioned projects. I have tried to use "Path Filters" but couldn't accomplish this. My pipeline creates a drop from the whole solution.
Already reviewed this but not found the solution.

Can anyone help on this?

The Source Code Path

Azure DevOPS CI Pipeline

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

此刻的回忆 2025-01-18 02:10:39

在.Net构建任务中,您可以将“项目路径”字段的值设置为解决方案中指定项目的路径。通配符表达式“**/*.csproj”将匹配并构建解决方案中的所有 C# 项目。

输入图像此处描述

对于您的情况,在 .Net 构建任务之后,您需要使用 复制文件任务,将工件文件从构建输出路径复制到 $(Build.ArtifactStagingDirectory)

输入图片此处描述

然后使用 **发布工件任务 ** 从 $(Build.ArtifactStagingDirectory) 发布工件文件。

输入图片此处描述

On the .Net build task, you can set the value of the field "Path to project(s)" to be the path of a specified project in the solution. The wildcard expression "**/*.csproj" will match and build all the C# projects in the solution.

enter image description here

For your case, after .Net build task, the you need to use the Copy Files task to copy the artifact files from the build output path to $(Build.ArtifactStagingDirectory).

enter image description here

Then use the **Publish Artifacts task ** to publish the artifact files from $(Build.ArtifactStagingDirectory).

enter image description here

作死小能手 2025-01-18 02:10:39

我们使用此代码来实现我们的多项目解决方案:

trigger:
 branches:
  include:
  - master
 paths:
  include:
    - src/Project1

pool:
  name: 'Default'
  vmImage: 'windows-latest'

variables:
  buildConfiguration: 'Release'

steps:
  - script: dotnet build src\Project1\Project1.csproj --configuration $(buildConfiguration)
    displayName: 'Building. Configuration: "$(buildConfiguration)"'
    name: 'build_solution'
    continueOnError: 'false'

  - script: dotnet test src\Project1\Project1.csproj --no-build --configuration $(buildConfiguration)
    displayName: 'Running tests'
    name: 'run_tests'
    continueOnError: 'false'

  - task: DotNetCoreCLI@2
    displayName: 'Publishing'
    name: 'publish'
    continueOnError: false
    inputs:
      command: 'publish'
      publishWebProjects: false
      projects: '**/Project1.csproj'
      arguments: '--configuration $(BuildConfiguration) --no-build --output $(Build.ArtifactStagingDirectory)'
      zipAfterPublish: true

  - task: PublishBuildArtifacts@1
    displayName: 'Publish build artifact'
    name: 'publish_build_artifact'
    continueOnError: false
    inputs:
      PathtoPublish: '$(Build.ArtifactStagingDirectory)'
      ArtifactName: 'Project1'
      publishLocation: 'Container'

we use this code to achieve that for our multi-project solution:

trigger:
 branches:
  include:
  - master
 paths:
  include:
    - src/Project1

pool:
  name: 'Default'
  vmImage: 'windows-latest'

variables:
  buildConfiguration: 'Release'

steps:
  - script: dotnet build src\Project1\Project1.csproj --configuration $(buildConfiguration)
    displayName: 'Building. Configuration: "$(buildConfiguration)"'
    name: 'build_solution'
    continueOnError: 'false'

  - script: dotnet test src\Project1\Project1.csproj --no-build --configuration $(buildConfiguration)
    displayName: 'Running tests'
    name: 'run_tests'
    continueOnError: 'false'

  - task: DotNetCoreCLI@2
    displayName: 'Publishing'
    name: 'publish'
    continueOnError: false
    inputs:
      command: 'publish'
      publishWebProjects: false
      projects: '**/Project1.csproj'
      arguments: '--configuration $(BuildConfiguration) --no-build --output $(Build.ArtifactStagingDirectory)'
      zipAfterPublish: true

  - task: PublishBuildArtifacts@1
    displayName: 'Publish build artifact'
    name: 'publish_build_artifact'
    continueOnError: false
    inputs:
      PathtoPublish: '$(Build.ArtifactStagingDirectory)'
      ArtifactName: 'Project1'
      publishLocation: 'Container'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文