0

I'm having a custom property on my project to build the same app with different ressources (images).

project.jsproj

<ItemGroup>
    <Content Condition="$(Customization) == ''" Include="images\uwp\*.png" />
    <Content Condition="$(Customization) != ''" Include="images\$(Customization)\uwp\*.png" />
</ItemGroup>

this works fine via msbuild:

msbuild project.jsproj /property:Configuration=Release;Platform=x64;Customization=theme_xy

My question is if there is a possibility to preset this custom property on a solution on VisualStudio that will be applied on a build there as well.

For example:

a) Solution1.sln embedds project.jsproj with Customization property empty

b) Solution2.sln embedds project.jsproj with Customization property = "theme_xy"

Any help is appreciated - thanks

kerosene
  • 930
  • 14
  • 31

2 Answers2

1

if there is a possibility to preset this custom property on a solution on VisualStudio that will be applied on a build there as well.

The answer is yes, but the conditional limit is that you could not use the same project.jsproj file in Solution1.sln and Solution2.sln. You can set a PropertyGroup in the project.jsproj file in Solution1.sln:

    <PropertyGroup>
        <Customization></Customization>
    </PropertyGroup>
    <ItemGroup>
       <Content Condition="$(Customization) == ''" Include="images\uwp\*.png" />
       <Content Condition="$(Customization) != ''" Include="images\$(Customization)\uwp\*.png" />
    </ItemGroup>

That is equivalent to change the project.jsproj file in solution1.sln:

  <ItemGroup>
    <Content Include="images\uwp\*.png" />
  </ItemGroup>

In the Solution2.sln, you need to change the project.jsproj file:

  <PropertyGroup>
    <Customization>theme_xy</Customization>
  </PropertyGroup>

But if you want use the same project.jsproj in the solution1.sln and solution2.sln without any other extra changes, you still need set Condition for the PropertyGroup and this Condition need to be transferred from outside of VS, like command line. In this case, you could not embeds the same project.jsproj with conditional custom properties in different solutions.

<PropertyGroup Condition="$(Customization) == ''">
    <Customization></Customization>
  </PropertyGroup>
Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • Thanks to clarify things: I want to use the same project.jsproj on both solutions. Basically my question was if there is a way to provide this external Condition via VS, but apparently that is not possible. – kerosene Apr 05 '17 at 07:54
  • 1
    I think it should be, we could not provide this external Condition via VS itself. – Leo Liu Apr 05 '17 at 08:03
  • solved it by setting property based on Solution name: ` theme_xy ` – kerosene Apr 05 '17 at 08:16
0

Solved this problem by differentiation of Solution name:

<PropertyGroup>
    <Customization></Customization>
</PropertyGroup>

<PropertyGroup Condition="'$(SolutionName)' == 'Solution1'">
    <Customization>theme_xy</Customization>
</PropertyGroup>
kerosene
  • 930
  • 14
  • 31