In my WPF project I use some third-party platform-specific dlls, e.g. if Platform is x86 then x86-versions of that dlls are copied into Output folder, and if platform is x64 then x64 versions are.
These dlls also require Visual C++ Redistributable. So I need it to be a Prerequisite to be installed when ClickOnce setup runs. The problem is I need only x64 version of C++ redist for x64 platform, and x86 for x86 platform. But I cannot just write
<BootstrapperPackage Include="Microsoft.Visual.C++.14.0.x64" Condition="'$(Platform)' == 'x64'">
<Visible>False</Visible>
<ProductName>Visual C++ "14" Runtime Libraries %28x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Visual.C++.14.0.x86" Condition="'$(Platform)' == 'x86'">
<Visible>False</Visible>
<ProductName>Visual C++ "14" Runtime Libraries %28x86%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
because <BootstrapperPackage> tag doesn't support Condition attribute.
It is also impossible to write multiple <ItemGroup> tags with <BootstrapperPackage>s inside them because Visual Studio turns
<ItemGroup>
<!--common BootstrapperPackages-->
</ItemGroup>
<ItemGroup Condition="'$(Platform)' == 'x86'">
<!--BootstrapperPackages for x86-->
</ItemGroup>
<ItemGroup Condition="'$(Platform)' == 'x64'">
<!--BootstrapperPackages for x64-->
</ItemGroup>
into
<ItemGroup />
<ItemGroup Condition="'$(Platform)' == 'x86'" />
<ItemGroup Condition="'$(Platform)' == 'x64'">
<!--All BootstrapperPackages: common, for x86 and for x64-->
</ItemGroup>
I cannot include both packages, because on x86 systems the installer of x64 C++ will show an error, and on x64 systems x86 C++ will be installed but it won't be used.
How can I overcome these difficulties and specify different BootstrapperPackages for different platforms?