Multiline string in Azure Pipelines

后端 未结 3 1484
轮回少年
轮回少年 2020-12-21 07:35

Can I use a multiline YAML string in Azure Pipelines?

Using the ASP.NET Core (.NET Framework) template I tried multilining the msbuildArgs but that didn

相关标签:
3条回答
  • 2020-12-21 07:39

    You can just put ' in the start and the end of the msbuildArgs:

    - task: VSBuild@1
      displayName: 'Build solution **\*.sln'
      inputs:
        vsVersion: latest
        msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package 
        /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true'
    
    0 讨论(0)
  • 2020-12-21 07:42

    I always use the YAML block chomping operator like this

    msbuildArgs: >-
      /p:DeployOnBuild=true
      /p:WebPublishMethod=Package
      /p:PackageAsSingleFile=true
      /p:SkipInvalidConfigurations=true
      /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip"
      /p:DeployIisAppPath="Default Web Site"
    

    Works well and makes things crystal clear and neat

    0 讨论(0)
  • 2020-12-21 07:44

    Multiline string in Azure Pipelines

    Shayki Abramczyk pointed out the key to the this error.

    Just put one ' in the start and the end of the msbuildArgs without having to configure for each MSBuild argument

    As test, following YAML work for me:

    - task: VSBuild@1
      displayName: 'Build solution YourSolution'
      inputs:
        solution: $(solution)
        msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
        platform: '$(buildPlatform)'
        configuration: '$(buildConfiguration)'
    

    Note: The variable $(solution) should point to a specific solution .sln or project .csproj file instead of **\*.sln. If you have one more solution in your repo, you may get the error Only one project can be specified.

    Update:

    but I don’t want super long run-on line as in your answer provided. I want to split across multiple lines!

    If you do not want to super long run-on line as in MSBuild arguments, you could split them directly, but pay attention to indentation, like:

    - task: VSBuild@1
      displayName: 'Build solution YourSolution'
      inputs:
        solution: $(solution)
        msbuildArgs: '/p:DeployOnBuild=true
                      /p:WebPublishMethod=Package 
                      /p:PackageAsSingleFile=true 
                      /p:SkipInvalidConfigurations=true 
                      /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" 
                      /p:DeployIisAppPath="Default Web Site"'
        platform: '$(buildPlatform)'
        configuration: '$(buildConfiguration)'
    

    As test, it works fine.

    Hope this helps.

    0 讨论(0)
提交回复
热议问题