How to build multiple configurations in a single VSTS build


When I try to build debug and release at the same time I get the following error:

The specified solution configuration "release, debug|any cpu" is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those properties blank to use the default solution configuration.


Enable the Multi-configuration option.



By default the Multi-configuration option is disabled. To build multiple configurations at once, you actually have to do more than just check the box. First you need to update the BuildConfiguration variable to a comma-delimited string of configurations.

  1. Select the build
  2. Click the Edit link
  3. Click the Variables tab
    Field Value
    BuildConfiguration release,debug


With the build configuration updated, you can now enable the Multi-configuration option.

  1. Click the Options tab
  2. Check the Multi-configuration checkbox
    Field Value
    Multipliers BuildConfiguration
  3. Click Save

Now when you queue a new build, both configurations will build.


Comments (32) -

  • Thank you! Your post here helped me after about a week of testing and searching for the correct way to build multiple configurations.
  • Donovan, is it possible to build multiple configurations in a single queue?
    For now another builds wedged between each configuration and Multi-configuration build takes a long time.
  • Hello, Donovan!
    Is it possible to make Multi-configuration build in a single queue?
    For now another builds wedged between building each configuration and Multi-configuration build takes a long time.
    • If you only have a single agent in your queue each build will happen one after the other.  If your builds to happen at the same time you must have multiple agents in your queue.  
  • Quick question. If I have a release and debug version of a website, how do you stop it from building into the same zip, etc?
    • Change MSBuild Arguments from:
      /peployOnBuild=true /p:WebPublishMethod=Package /packageAsSingleFile=true /p:SkipInvalidConfigurations=true /packageLocation="$(build.artifactstagingdirectory)\\"

      /peployOnBuild=true /p:WebPublishMethod=Package /packageAsSingleFile=true /p:SkipInvalidConfigurations=true /packageLocation="$(build.artifactstagingdirectory)\\$(BuildConfiguration)\\"

      By adding $(BuildConfiguration) each config will get a different zip.
      • Objective: I want to  have a single Build only, and to release it to different environment by changing the web.config using tokenizer..!!!
        Im struck at a point where I get a build package as zip folder inside which I have only single web.config file. how to proceed after this.
        • You have a couple options. One use an extension to unzip the file. Change the web.config and re-zip the file. Option two is don't zip in your build and publish the unzipped site as an artifact to release. That way when release downloads the artifact the web.config is there to be transformed. Then in release you zip the files and deploy.
          • Donovan, can you provide me any source which can help me to achieve my Objective? i Want to use tokenizer but it is expecting json. Any source where i get any help regarding the same.?
            • Which tokenizer task are you using? I use the one from Colin and it is not based on json. Just vars in the build or release.
  • Hey Donovan,

    Can CD release definitions with Multi-configuration builds?
    I have configured this multi-configuration build + CD Release definition for some 4-5 configurations in my current project. However the challenge that I have is if for eg. my environments are dev, bvt, st, sit in the same order in same build and release definition to deploy one after other, and If I need to build only DEV and ST, then the Release will get created and deployed on DEV alright. But after deploying on dev it will look for BVT artifact which it won't find so it will fail the release deployment on BVT and it won't go further and deploy on ST.
    Do you have any ideas for this that the release should somehow figure out that the the artifact is available for specific configurations and should deploy only to those environments?
    • I would like to better understand why you are not deploying the same bits in each environment. What is different in each config?
      • That is because each environment configuration file has urls etc for that specific environment in Azure. Our environment corresponds to a Resource group in Azure.
        • I would recommend you use tokenization to config changes between environments. That way you deploy the exact build in every environment and have release management update the configuration values as part of the release. This extension has the tasks you need
          This will help you adhere to DevOps best practices. You want to deploy the same build in every environment and not a build per environment.
          • Hi Donovan,

            We have tried that for webapp deployment. But it doesnot work for Service Fabric API deployment and also for SSDT post deployment scripts Frown
            Also is there any way to deploy configuration seperately after the main code is deployed for service fabric, webapp?
          • Hi Donovan, Does this extension work with Xamarin apps?
          • Hi Donovan,

            our project consists of multiple release environments and therefor is using multiple configurations:
            "Web.config" (unoptimized builds, full debug info)
            "Web.Release (Test).config" (optimized builds, full debug info)
            "Web.Release (Production).config" (optimized builds, pdb-only debug info)

            According to your comment about DevOps best practices, we should build a single artifact and configure it later on in Release Management.

            Now the question is: How can we have TFS produce the environment specific DLLs and PDBs with full or minimal debug information when building once?

            On another note, how would we be able to differentiate between those builds?

            Please guide us.

            Thank you,
  • Hi Donovan,
    I have a Powershell script / Shell script task to update a app secret to a configuration. But when using Multi-Configuration, Is there a way to rerun the script as a pre-condition to the next configuration. Any suggestion how to handle this use case.

    We would like to make use of Multi-Configuration feature but at the same time need to update the Mobile Center app secrets for different build configuration.

    TFS version: TFS 2015 On-Premise hosted.
    Type of app: Xamarin native apps.

  • Hi Donovan,

    We have a case where the BuildConfiguration is used in one of the bash shell script to update the app secrets for the active build config. But when using the Multi Configuration option the BuildConfiguration parameter holds comma separated config names. Is there pre defined build variable to get hold of the configuration used to build from the shell script?

  • Hi Donovan,

    I'm very new to TFS.
    I'm trying to build and package multi targeted Framework nuget packages (netstandard1.6,net462) .
    Is that also possible with the Multi-configuration option?
    Any recommendations?

  • Hi Donovan,
    Thanks for this information, i have updated my build definition to support multiple configuration. everything is now working fine but i am getting "Artifact WWW already exists for build 5150.error ", in my build definition i have one artifact to publish the code, for release version it is working fine but for debug it is giving error "Artifact WWW already exists for build 5150."
    Any recommendations?
    • Make sure if you are publishing twice that the names are different. Maybe www_debug and www_release.
  • Hey Donovan, thanks for the blog post. It got me pointed in the right direction. However, it is apparently out-of-date due to some changes in VSTS.

    Would you please make a note in the post that "Multi-configuration" is now configured on the "Run on agent" task (in the "Execution plan" section)?

    The following Stack Overflow answer revealed the new location for this option:

  • Hi Donovan, thanks for your work on this.

    So, I'm moving from a 2012 Build def to new web build def. How would I implement the following multi configurations, cut and pasted from my current build def:



    Configuration | Platform

    Debug | WhateverApps
    Release | WhateverApps
    Release | WhateverApps64
    Release | WhateverAppsCloud

    This is easily set up using the UI in my current process. As you can see we only build the Debug of WhateverApps and the release of the rest. Actually - now that I am through writing this - I guess I can create 2 Visual Build steps, 1 for the debug |Relase of whateverApps and one for the release of everything else. Is that be the correct way to do this? Thanks.
  • Hi Donovan,
    In the solution there are projects with Build Platform = Any CPU and x86. (Mixed Platforms).
    It builds fine in Visual studio. but in vsts, when Build Platform is set to any cpu, x86 projects are not built and caused
    error in building other projects depending on x86 projects.
  • Hi Donovan,

    I am using VSTS for building .sln files, but whenever I am trying to build only in Release Mode , it gets triggered in both Debug and Release Mode. Can you tell me as to where am I possibly going wrong.
    And the second issue is the Quality Gates shows timeout error, thus unable to generate Code Analysis Report .how am I suppose to fix it .
    • I would review your configuration settings from within Visual Studio. Make sure the config names are what you are expecting. Then check your build configuration in VSTS to make sure the build configuration is being set correctly.  Finally I would check the task to build the .sln and make sure it is being passed the build configuration variable.
      • Thank you.
        What about the Quality gates extension,they are showing successfull  but no code coverage results as they are timed out
  • Hi Donovan,
    Is there any way to have a custom build run on VSTS? I've tried many configuration but none have succeeded. What I mean is, in the Visual Studio, you can create a new build configuration from the drop-down menu, by default there's "debug", and "release". But let's say I want to create a build configuration where I want to skip building one of the projects, so going in the dropdown I can create a new build configuration, "my-build", and in that one, uncheck the project that I don't want to be build in this configuration. But how I can achieve this in VSTS? I tried to go to variable tab, and set the "BuildConfiguration" variable to "my-build", but of course, when I queued the build it came up with (expected) error saying invalid build configuration, "my-build|any cpu" is invalid, which makes perfect sense as the VSTS agent doesn't know about this custom build configuration that I've created in my visual studio. So is there a way to get this done on VSTS?

Add comment