MSBuild Batching - Can't figure out how to get a target to be run only for some Solutions
I have something like this in my TFSBuild.proj
<ItemGroup>
<SolutionToBuild Include="$(BuildProjectFolderPath)/../../ProjectA/ProjectA.sln" />
<SolutionToBuild Include="$(BuildProjectFolderPath)/../../x64 Installer/x64 Installer.sln" Condition="'$(Platform)' == 'x64' " />
<SolutionToBuild Include="$(BuildProjectFolderPath)/../../x86 Installer/x86 Installer.sln" Condition="'$(Platform)' == 'x86' " />
<ConfigurationToBuild Include="Release|x86">
<FlavorToBuild>Release</FlavorToBuild>
<PlatformToBuild>x86</PlatformToBuild>
</ConfigurationToBuild>
<ConfigurationToBuild Include="Release|x64">
<FlavorToBuild>Release</FlavorToBuild>
<PlatformToBuild>x64</PlatformToBuild>
</ConfigurationToBuild>
</ItemGroup>
I want to override the BeforeCompile target to run a custom task I have written. The custom task will take the output from ProjectA and build file that is used by both installer projects (Wix project files). How to I get the BeforeCompile target to only execute for those two SolutionToBuild items? I assume this is about Target Batching (because I can then u开发者_JAVA百科se conditions on my task, but I don't get it.
I tried adding something like this to see if it would work, but only the first solution is output to the log:
<Target Name="BeforeCompile" Outputs="%(SolutionToBuild.Identity)">
<Message Text="Solution being built: %(SolutionToBuild.Identity)" />
</Target>
Why don't you compile ProjectA and prepare the needed files before you build the actual WiX installation?
<ItemGroup>
<SolutionToBuild Include="$(BuildProjectFolderPath)/../../x64 Installer/x64 Installer.sln" Condition="'$(Platform)' == 'x64' " />
<SolutionToBuild Include="$(BuildProjectFolderPath)/../../x86 Installer/x86 Installer.sln" Condition="'$(Platform)' == 'x86' " />
<ConfigurationToBuild Include="Release|x86">
<FlavorToBuild>Release</FlavorToBuild>
<PlatformToBuild>x86</PlatformToBuild>
</ConfigurationToBuild>
<ConfigurationToBuild Include="Release|x64">
<FlavorToBuild>Release</FlavorToBuild>
<PlatformToBuild>x64</PlatformToBuild>
</ConfigurationToBuild>
</ItemGroup>
<Target Name="BeforeCompile">
<MsBuild Projects="$(BuildProjectFolderPath)/../../ProjectA/ProjectA.sln"/>
<CallTarget Targets="PrepareWiXFiles"/>
</Target>
That way you will not need to do the nasty name checking.
A far better approach is to split this build into several small ones which will improve the maintainability. For example, you can create one build that will build ProjectA and store its outputs to a network location (or local one). Then you create a second build that will gather the output from ProjectA prepare the WiX files and build the Wix Installer.
Hope this helps.
精彩评论