0

我的项目中有一个自定义属性,可以使用不同的资源(图像)构建相同的应用程序。

项目.jsproj

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

这可以通过 msbuild 正常工作:

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

我的问题是是否有可能在 VisualStudio 上的解决方案上预设此自定义属性,该解决方案也将应用于那里的构建。

例如:

a) Solution1.sln嵌入 project.jsproj 自定义属性为

b)Solution2.sln嵌入 project.jsproj 与自定义属性 = “ theme_xy

任何帮助表示赞赏 - 谢谢

4

2 回答 2

1

如果有可能在 VisualStudio 上的解决方案上预设此自定义属性,该解决方案也将应用于那里的构建。

答案是肯定的,但是条件限制是不能在Solution1.sln和Solution2.sln中使用同一个project.jsproj文件。您可以在 Solution1.sln 的 project.jsproj 文件中设置一个 PropertyGroup:

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

相当于修改了solution1.sln中的project.jsproj文件:

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

Solution2.sln中,您需要更改 project.jsproj 文件

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

但是,如果您想在 solution1.sln 和 solution2.sln 中使用相同的 project.jsproj 而不进行任何其他额外更改,您仍然需要为 PropertyGroup 设置 Condition 并且此 Condition 需要从 VS 外部传输,如命令行。在这种情况下,您不能在不同的解决方案中嵌入具有条件自定义属性的相同 project.jsproj。

<PropertyGroup Condition="$(Customization) == ''">
    <Customization></Customization>
  </PropertyGroup>
于 2017-04-05T05:26:04.207 回答
0

通过区分解决方案名称解决了这个问题:

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

<PropertyGroup Condition="'$(SolutionName)' == 'Solution1'">
    <Customization>theme_xy</Customization>
</PropertyGroup>
于 2017-04-05T08:21:37.927 回答