question

SamCarleton-3109 avatar image
0 Votes"
SamCarleton-3109 asked TianyuSun-MSFT answered

error MSB4126: The specified solution configuration "Release|AnyCPU" is invalid.

I am upgrading my VS2015 proj file to VS2019 and running into this error:

error MSB4126: The specified solution configuration "Release|AnyCPU" is invalid.

From the cmdline I am executing the following:

 @call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64_x86
 msbuild BuildReleaseVS2019.proj /target:MainApplication

Here is the BuildReleaseVS2019.proj file:

 <?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="4.7.3" DefaultTargets="All" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    
   <PropertyGroup>
     <CppIncludes>..\include</CppIncludes>
     <LibsPath>..\lib</LibsPath>    
   </PropertyGroup>
      
   <Target Name="MainApplication" DependsOnTargets="licenseMgr">
     <Message Text="*** Target MainApplication" />
     <MSBuild Projects="GM\MainApplication.sln" Properties="Configuration=Release;Platform=AnyCPU"/>
   </Target>
    
   <Target Name="licenseMgr">
     <Message Text="*** Target licenseMgr" />
     <MSBuild Projects="..\licenseMgr\LicenseLib\LicenseLib2019.vcxproj" Properties="Configuration=Release;Platform=Win32" Targets="Rebuild"/>
   </Target>
      
 </Project>

And then in the csproj file this is defined:

   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
     <OutputPath>bin\Debug\</OutputPath>
     <DefineConstants>TRACE;DEBUG</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
     <UseVSHostingProcess>true</UseVSHostingProcess>
     <PlatformTarget>x86</PlatformTarget>
     <Prefer32Bit>true</Prefer32Bit>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>pdbonly</DebugType>
     <Optimize>true</Optimize>
     <OutputPath>bin\Release\</OutputPath>
     <DefineConstants>
     </DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
     <PlatformTarget>x86</PlatformTarget>
     <Prefer32Bit>true</Prefer32Bit>
   </PropertyGroup>

Any suggestions on how to resolve this issue?

vs-msbuild
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

TianyuSun-MSFT avatar image
0 Votes"
TianyuSun-MSFT answered

Hi @SamCarleton-3109 ,

Welcome to Microsoft Q&A forum.

Did you also set following Configuration and Platform properties in your csproj file?

     <Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>

Best Regards,
Tianyu


If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.