簡體   English   中英

Azure 構建任務 - 僅從所有解決方案構建一個項目

[英]Azure build task - build only one project from all solution

我在 ci/cd 中遇到了 azure 任務的問題,每個版本都有一個在部署代碼之前運行的測試任務,並且每次構建所有解決方案都需要時間。 我希望只構建與發布相關的特定項目,而不是所有解決方案。 我該如何解決?

根據您的 SO 標簽,您似乎正在使用 C#。

  • 在構建任務中構建一個針對.net framework特定項目:

    您應該使用MSBuild task而不是Visual Studio Build task

    在此處輸入圖片說明

  • 在構建任務中構建一個針對.net core/standard特定項目:

    您應該將Dotnet build與這種輸入一起使用:

    在此處輸入圖片說明

  • 此外,如果您在發布任務中使用 Dotnet 測試,它會自動構建要測試的項目,除非您添加--no-build開關。 因此,您還需要確保指定要測試的特定項目而不是使用**/*.csproj

    在此處輸入圖片說明

trigger:
  branches:
    include:
    - master
    
pool:
  name: Azure Pipelines
  vmImage: 'windows-2019'
  demands:
    - msbuild
    - visualstudio

variables: 
  BuildConfiguration: "Release"
  platform: any cpu
  BuildPlatform: any cpu

name: 1.$(build.buildid)

stages:
- stage: Build
  jobs:
  - job: Build  
    steps:
    - task: NuGetToolInstaller@0
      displayName: 'Use NuGet 4.4.1'
      inputs:
        versionSpec: 4.4.1
    - task: NuGetCommand@2
      displayName: 'NuGet restore'
      inputs:
        restoreSolution: 'path to sln file/xxxxxxx.sln'
        vstsFeed: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'        
    - task: VSBuild@1
      displayName: 'Build solution'
      inputs:
        solution: 'path to sln file/xxxxxxx.sln'
        platform: '$(BuildPlatform)'
        configuration: '$(BuildConfiguration)'
        clean: true

此外,如果選擇了相應的 sln 文件,則在初始步驟簽入管道在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM