Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 781
jmoreno Avatar asked Jan 29 '18 12:01

jmoreno


2 Answers

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)'
like image 26
Ziebell-INL Avatar answered Oct 16 '22 17:10

Ziebell-INL


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

like image 85
jmoreno Avatar answered Oct 16 '22 18:10

jmoreno