Azure DevOps上的MsBuild任务:对相关项目使用不同的配置 [英] MsBuild Task on Azure DevOps: with different configuration for dependent projects

查看:70
本文介绍了Azure DevOps上的MsBuild任务:对相关项目使用不同的配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含多个项目的解决方案.

i have one solutions with multiple projects.

DSS.DMN.Client项目依赖于其他项目(具有引用)

DSS.DMN.Client project dependens on other projects(have references)

这是我的Yaml文件的样子

This is how my yaml files looks like

- task: MSBuild@1
  displayName: 'Build solution Client'
  inputs:
    platform: anyCPU
    maximumCpuCount: true
    configuration: 'Integration' 
    solution: DSS.DMN.Client

- task: CopyFiles@2
  inputs:
    SourceFolder: '$(Build.SourcesDirectory)'
    Contents: '**\bin\**'
    TargetFolder: '$(Build.ArtifactStagingDirectory)'

- task: PublishBuildArtifacts@1    
  displayName: 'Publish Artifact: drop'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'

问题是客户端将配置配置为INT,而其他两个从属项目将配置配置为调试.

the thing is that Client have configuration as INT but the other two dependent projects have configuration as debug.

现在,当我运行构建时,出现错误:

now when i run the build i get the error:

##[error]C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(777,5): Error : The OutputPath property is not set for project 'DSS.DMN.AVModule.csproj'.  Please check to make sure that you have specified a valid combination of Configuration and Platform for this project.  Configuration='INT'  Platform='AnyCPU'.  You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project.

问题是尽管它只有调试配置,但是构建正在尝试为DSS.DMN.AVModule.csproj的项目查找INT配置.

the problem is build is trying to find INT configration for the project for DSS.DMN.AVModule.csproj though it have only debug configuration.

问题:如何在一个构建中为不同项目的构建流水线提供不同的配置?

question: How do i provide differernt configation on my build pipeline for different project in a single build?

推荐答案

尝试一下-注意文件夹src/我的项目在src根文件夹下

try this - attention in folder src/ my project is under src root folder

name: functions-name

trigger:
  branches:
    include:
    - main
  paths:
    include:
    - src/*
    exclude:
    - README.md

variables:
- name: functionAppName
  value: 'func-name-env'
- name: azureSubscriptionENV
  value: 'Azure ENV'
- name: vmImageName
  value: 'windows-2019'
- name: workingDirectory
  value: 'src/xxx.Functions'
- name: systemName
  value: BatchAllocation

pool:
  vmImage: $(vmImageName)

stages:
- stage: Build
  displayName: Build stage

  jobs:
  - job: Build
    displayName: Build
    pool:
      vmImage: $(vmImageName)

    steps:

    - task: NuGetCommand@2
      inputs:
        command: 'restore'
        restoreSolution: '**\*.sln'
        feedsToUse: 'config'
        noCache: false
    
    - task: VSBuild@1
      inputs:
        solution: '**\*.sln'
        msbuildArgs: '/p:DeployOnBuild=true /p:SkipInvalidConfigurations=false /p:OutDir="$(System.DefaultWorkingDirectory)\publish_output"'
        platform: 'Any CPU'
        configuration: 'Release'

    - task: ArchiveFiles@2
      displayName: 'Archive files'
      inputs:
        rootFolderOrFile: '$(System.DefaultWorkingDirectory)/publish_output'
        includeRootFolder: false
        archiveType: zip
        archiveFile: $(Build.ArtifactStagingDirectory)/$(systemName)-v$(Build.BuildId).zip
        replaceExistingArchive: true

    - publish: $(Build.ArtifactStagingDirectory)/$(systemName)-v$(Build.BuildId).zip

这篇关于Azure DevOps上的MsBuild任务:对相关项目使用不同的配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆