【问题标题】:MsBuild Task on Azure DevOps: with different configuration for dependent projectsAzure DevOps 上的 MsBuild 任务:依赖项目的不同配置
【发布时间】:2020-05-07 15:10:51
【问题描述】:

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

DSS.DMN.Client 项目依赖于其他项目(有参考)

这就是我的 yaml 文件的样子

- 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,但其他两个依赖项目的配置为调试。

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

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

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

问题:如何在我的构建管道上为单个构建中的不同项目提供不同的配置?

【问题讨论】:

  • 您是否尝试过在管道中使用 msbuild 任务构建每个项目,然后将 dll 文件复制到引用项目中?
  • @LeoLiu-MSFT:我将 MsBuild 转换为 vsbuild@1 并且成功了。
  • 很高兴您解决了您的问题。既然你已经解决了,请将你的评论转换为答案吗?这可能有利于其他社区成员阅读答案,避免在已经有答案的帖子上花费大量时间。谢谢。

标签: azure-devops azure-pipelines devops azure-pipelines-build-task


【解决方案1】:

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

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
    workspace:
      clean: all

    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

【讨论】:

  • 非常感谢您的回复。不幸的是,我不再在那个项目上工作,所以不能再测试它了。但是,我感谢您的回复一百万。对此表示赞同。希望该解决方案将来对我有所帮助。再次感谢。
  • Felipe,很棒的 yaml,我有一个关于发布的问题。您在哪里发布该 zip 文件?
  • 压缩文件将发布在您的管道上。将有一个包含已发布文件的选项...我将使用图像更新此主题@VAAA
  • 非常感谢@FelipeAugusto
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-04-08
  • 1970-01-01
  • 2023-04-04
  • 1970-01-01
相关资源
最近更新 更多