9
votes

I was working on migrating a website to a web project, I updated the project and everything is fine locally, I've switched to building the solution instead of the project. But when building on the build server, I'm getting an error message

c:\agent_work\10\s\mySolution.sln.metaproj(0,0): Error MSB4126: The specified solution configuration "Debug|AnyCPU" 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.

What is wrong and more importantly, what do I do to fix it?

2
What you could do here is to make sure that you are building a valid solution configuration. In Visual Studio, right-click your solution and select "Configuration Manager". Here you specify what solution configuration that exist and what projects that are build for each.Danko Valkov

2 Answers

15
votes

The problem is simple as indicated in the error message. The configuration name does not match any of the configurations defined in the solution.

The solution is likewise simple: either create a configuration that matches the name and add it to your solution, or change the configuration name being used to build the application. The build solution step has textbox where you enter the BuildPlatform, the content is $(BuildPlatform). The value for that is set in the Variables section. In this case it needs to be changed from "AnyCPU" to "Any CPU" (i.e. add a space between Any and CPU).

enter image description here

0
votes

For Azure DevOps Server 2020, add a variable to your azure-pipelines.yml file before the steps.

variables:
  buildConfiguration: 'Debug'

Example use:

- task: DotNetCoreCLI@2
  displayName: 'Building Projects'
  inputs:
    command: 'build'
    projects: '$(Build.SourcesDirectory)/**/*.sln'
    arguments: '--configuration $(buildConfiguration)'