Search code examples
azureazure-pipelines-build-taskazure-pipelines-yamlsln-file

Azure Pipelines VSBuild configuration is invalid


I am new to Azure and I have inherited a pipeline which was built by someone else who is no longer with the company. It's broken in many ways, so I am attempting to build a new one based on the original broken one I was given. I am doing this one command at a time to fix the issues as i go. Currently the following task is failing:

- task: VSBuild@1
    displayName: Build Solution
    inputs:
      solution: $(BuildParameters.solution)
      msbuildArgs: /p:DeployOnBuild=true /p:WebPublishingMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\$(BuildConfiguration)\\"
      platform: $(BuildPlatform)
      configuration: $(BuildConfiguration)

I have researched other similar stack overflow posts but still can't figure out what the issue is. The warning I am receiving is this:

Warning MSB4126: The specified solution configuration "$(BuildConfiguration)|$(BuildPlatform)" 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.

Here is what I have tried so far:

  1. I tried removing both the platform and configuration settings (the last two lines of the first quoted code above). This resulted in 54 other warnings so that seemed like a bad idea.

  2. next I put those two lines back in that I had deleted and instead i added this: /p:Configuration=Debug /p:Platform="Any CPU" to the very begining of the parameter string listed on the msbuildArgs setting. This got rid of the 54 new warnings and brought back the original error (in other words it had no effect)

Also this other stack overflow question: TFS Build error MSB4126 (solution configuration is invalid) how to fix seems to have an a solution for this, however I can't figure out how to actually apply this solution. There is a screenshot of the Azure UI in that ticket and I can't even figure out how to get to that page of Azure to see those options. My guess is that this person is not using a yaml file to set up the pipeline and doing it the old way, but I do not want to configure it that way because I would prefer to have the yaml file define the pipeline and have this stored in my git repo.

Note: I have also been looking at the sln file associated with this project to try to make sense out of it, I think I get the basic idea of this file not sure...

Any advice will help, thanks


Solution

  • It looks like there two variables aren't defined:

    $(BuildConfiguration)
    $(BuildPlatform)
    

    Make sure the variables are defined in your pipeline yaml or on the variables tab.

    See:

    Set the values to the ones that make sense for the solution. We can't guess these values, as they are usually specific to the solution being built.