MSBuild "error MSB4126: invalid solution configuration" in CI
You passed a Configuration or Platform to the build that the solution does not define. MSB4126 means the combination (for example Release|x64) is not in the solution's configuration list.
What this error means
msbuild or dotnet build fails with "error MSB4126: The specified solution configuration "Release|x64" is invalid. Please specify a valid solution configuration."
dotnet
error MSB4126: The specified solution configuration "Release|x64" is invalid.
Please specify a valid solution configuration using the Configuration and Platform properties.Common causes
A Platform the solution does not define
The solution only defines Any CPU, but the build passes x64, so the configuration pair does not exist.
A misspelled Configuration name
A Configuration value that does not match any solution configuration (a typo or a renamed build) is rejected.
How to fix it
Pass a configuration the solution defines
- List the solution configurations (in the .sln or your IDE).
- Use a
Configuration/Platformpair that exists, for exampleReleasewithAny CPU. - Re-run the build.
Terminal
dotnet build MySolution.sln -c Release -p:Platform="Any CPU"Add the missing solution configuration
If the platform is intentional, add the configuration/platform mapping to the solution so it resolves.
Terminal
# Open the solution and add the Release|x64 mapping
# under SolutionConfigurationPlatforms, then commit the .slnHow to prevent it
- Reference only configurations defined in the solution.
- Keep platform names consistent (
Any CPUvsx64). - Validate
-c/-p:Platformagainst the solution before CI.
Related guides
MSBuild "error MSB1009: Project file does not exist" in CIFix "error MSB1009: Project file does not exist" during dotnet build in CI - the path passed to build or rest…
MSBuild "error MSB4019: imported project was not found" in CIFix "error MSB4019: The imported project X was not found" during dotnet build in CI - an Import in the projec…
MSBuild "error MSB4181: the task returned false but did not log an error" in CIFix "error MSB4181: The X task returned false but did not log an error" during dotnet build in CI - a custom…