0

I am trying to build my project using MSbuild. The solution builds perfectly fine if I hardcode the configurations

<MSBuild Projects="%(SolutionsToBuild.Identity)" Properties="Configuration=Debug" ContinueOnError="false"/>
<MSBuild Projects="%(SolutionsToBuild.Identity)" Properties="Configuration=Release" ContinueOnError="false"/>

but if I use batching like this the values are not assigned

<MSBuild Projects="%(SolutionsToBuild.Identity)" Properties="Configuration=%(ConfigList.Identity)" ContinueOnError="false"/>

where ConfigList

<ItemGroup>
                <ConfigList Condition=" '@(ConfigList)' == '' and $(Configuration) != '' " Include="$(Configuration.Split(';'))" />
                <!-- parse all requested configurations into a list -->
                <ConfigList Condition=" '@(ConfigList)' == '' " Include="Debug" />
                <!-- if no configurations were specified, default to Debug -->
</ItemGroup>

and Configurations are provided from CLI msbuild build.proj -p:Configuration="Release;Debug"

Also interestingly I am getting the value in <Message Text="Build for configuration %(ConfigList.Identity)"/>

Whole Code

<Target Name="BuildApplication">
            <ItemGroup>
                <ConfigList Condition=" '@(ConfigList)' == '' and $(Configuration) != '' " Include="$(Configuration.Split(';'))" />
                <!-- parse all requested configurations into a list -->
                <ConfigList Condition=" '@(ConfigList)' == '' " Include="Debug" />
                <!-- if no configurations were specified, default to Debug -->
            </ItemGroup>
            <Message Text="Build for configuration %(ConfigList.Identity)"/>            
            <MSBuild Projects="%(SolutionsToBuild.Identity)" Properties="Configuration=%(ConfigList.Identity)" ContinueOnError="false"/>
            <!--<MSBuild Projects="%(SolutionsToBuild.Identity)" Properties="Configuration=Debug" ContinueOnError="false"/>-->
</Target>

I am not sure what I am doing wrong. Any help would be appreciated. Thanks !

Sources referred: Using MSBuild to Build Multiple Configurations Passing properties to MSBUILD Task

user_19240589
  • 97
  • 1
  • 14
  • What is the error message? Could you please share the whole error with us. Did your project all targets to `net core`? If so, try to add `Targets="restore;build"`, restore is needed. `` – Mr Qian Dec 16 '20 at 09:48
  • @PerryQian-MSFT this is the error message ```error MSB4126: The specified solution configuration "| Any CPU" 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 def ault solution configuration.``` – user_19240589 Dec 16 '20 at 10:01
  • @PerryQian-MSFT we are not using .net core the solution would build on .net 472 – user_19240589 Dec 16 '20 at 10:02

0 Answers0