0

I have a new YAML pipeline in Azure DevOps with the following task:

- task: MSBuild@1
  displayName: 'Build MgzJsonService'
  inputs:
    solution: 'apps/MgzJsonService/MgzJsonService.csproj'
    platform: 'Any CPU'
    configuration: 'Release'
    msbuildArguments: '/p:OutputPath="$(build.artifactstagingdirectory)\MgzJsonService" /t:Build /m /p:RestorePackages=false /consoleloggerparameters:ErrorsOnly '
    clean: true

When the build is completed and the artifact is uploaded my Web.Config is not transformed using the Web.Release.config.

But when I add the same task twice, with Output Path another folder, the second build does transform my Web.Config using the Web.Release.config.

Why does it only work if I build the project twice?

Bartvandee
  • 289
  • 3
  • 19
  • You need share the Build configuration information for your first time, otherwise, no one knows how you configurate your task, so that could give any useful info. – Leo Liu May 05 '22 at 05:31
  • Hi @LeoLiu-MSFT thanks but the task above is how we configure it. Or what do you mean with Build Configuration? – Bartvandee May 05 '22 at 07:08
  • Is this your first time to configure the task? You said you add the same task twice, with **Output Path another folder**. As I know, the Web.Config transforme not related to the output path. It is related to tag for each config in the csproj file and rebuild. And most of the time, we use tasks to do the transformation rather than the build itself in the Azure devops: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/transforms-variable-substitution?view=azure-devops&tabs=Classic – Leo Liu May 05 '22 at 07:53
  • So I just found this post: https://stackoverflow.com/a/13128797/2074633 and that fixed my issue: "/p:UseWPP_CopyWebApplication=true /p:PipelineDependsOnBuild=false" – Bartvandee May 05 '22 at 08:08

1 Answers1

0

Adding the following to the MsBuildArguments in the task fixed the issue: "/p:UseWPP_CopyWebApplication=true /p:PipelineDependsOnBuild=false"

I got this answer from: https://stackoverflow.com/a/13128797/2074633

Bartvandee
  • 289
  • 3
  • 19