TFS Build error MSB4126 (solution configuration is invalid) how to fix
Asked Answered
P

3

14

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?

Phonogram answered 29/1, 2018 at 12:35 Comment(1)
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.Kaleidoscopic
P
19

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

Phonogram answered 29/1, 2018 at 12:47 Comment(3)
pretty stratight forward answer, this variables have to be created in VSTS as part of the definition of the buildGodgiven
For me, the variables were missing altogether and I had to add them in.Intertype
This is NOT the answer in all cases, especially if you're not using Vsiual Studio. The answer for me is the one provided by @AllanF below.Kirkland
R
1

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)'
Redvers answered 21/12, 2021 at 19:25 Comment(0)
P
1

Another consideration is .. Do you have an environment variable with variable name of PLATFORM ? and if so, what is the value you have assigned?

I have just corrected a problem with identical error message but in relation to MS Build usage from CAKE build tool by checking and change of value as per system environment variable with variable name of PLATFORM.

Poddy answered 7/2, 2024 at 5:4 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.