Skip to content

Commit

Permalink
Simply add auto initializer sources without a target, and define a us…
Browse files Browse the repository at this point in the history
…er-available property to add WindowsAppSDK-VersionInfo.cs exactly once (#3819)

* Use CoreCompileDependsOn to ensure that version info is added before XamlPreCompile, not just CoreCompile

* restructured to enable apps to easily include WindowsAppSDK-VersionInfo.cs exactly once for all compilations (Xaml, etc)

* removed cruft target
  • Loading branch information
Scottj1s committed Aug 30, 2023
1 parent e2c310d commit 043d811
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
13 changes: 7 additions & 6 deletions build/NuSpecs/Microsoft.WindowsAppSDK.Bootstrap.CS.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
<DefineConstants Condition="'$(WindowsAppSDKBootstrapAutoInitializeOptions_OnError_FailFast)'=='true'">$(DefineConstants);MICROSOFT_WINDOWSAPPSDK_BOOTSTRAP_AUTO_INITIALIZE_OPTIONS_ONERROR_FAILFAST</DefineConstants>
<DefineConstants Condition="'$(WindowsAppSDKBootstrapAutoInitializeOptions_OnNoMatch_ShowUI)'=='true'">$(DefineConstants);MICROSOFT_WINDOWSAPPSDK_BOOTSTRAP_AUTO_INITIALIZE_OPTIONS_ONNOMATCH_SHOWUI</DefineConstants>
<DefineConstants Condition="'$(WindowsAppSDKBootstrapAutoInitializeOptions_OnPackageIdentity_NoOp)'=='true'">$(DefineConstants);MICROSOFT_WINDOWSAPPSDK_BOOTSTRAP_AUTO_INITIALIZE_OPTIONS_ONPACKAGEIDENTITY_NOOP</DefineConstants>
<WindowsAppSdkIncludeVersionInfo>true</WindowsAppSdkIncludeVersionInfo>
</PropertyGroup>

<Target Name="GenerateBootstrapCS" BeforeTargets="BeforeCompile">
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)..\include\MddBootstrapAutoInitializer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)..\include\WindowsAppSDK-VersionInfo.cs" />
</ItemGroup>
</Target>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)..\include\MddBootstrapAutoInitializer.cs" />
</ItemGroup>

<!--Obsolete target retained to prevent build breaks-->
<Target Name="GenerateBootstrapCS" BeforeTargets="BeforeCompile" />

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
<DefineConstants Condition="'$(WindowsAppSDKDeploymentManagerAutoInitializeOptions_Default)'=='true'">$(DefineConstants);MICROSOFT_WINDOWSAPPSDK_DEPLOYMENTMANAGER_AUTO_INITIALIZE_OPTIONS_DEFAULT</DefineConstants>
<DefineConstants Condition="'$(WindowsAppSDKDeploymentManagerAutoInitializeOptions_None)'=='true'">$(DefineConstants);MICROSOFT_WINDOWSAPPSDK_DEPLOYMENTMANAGER_AUTO_INITIALIZE_OPTIONS_NONE</DefineConstants>
<DefineConstants Condition="'$(WindowsAppSDKDeploymentManagerAutoInitializeOptions_OnErrorShowUI)'=='true'">$(DefineConstants);MICROSOFT_WINDOWSAPPSDK_DEPLOYMENTMANAGER_AUTO_INITIALIZE_OPTIONS_ONERRORSHOWUI</DefineConstants>
<WindowsAppSdkIncludeVersionInfo>true</WindowsAppSdkIncludeVersionInfo>
</PropertyGroup>

<Target Name="GenerateDeploymentManagerCS" BeforeTargets="BeforeCompile">
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)..\include\DeploymentManagerAutoInitializer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)..\include\WindowsAppSDK-VersionInfo.cs" />
</ItemGroup>
</Target>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)..\include\DeploymentManagerAutoInitializer.cs" />
</ItemGroup>

<!--Obsolete target retained to prevent build breaks-->
<Target Name="GenerateDeploymentManagerCS" BeforeTargets="BeforeCompile" />

</Project>
6 changes: 5 additions & 1 deletion build/NuSpecs/Microsoft.WindowsAppSDK.Foundation.targets
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

Expand All @@ -13,4 +13,8 @@
<Import Project="$(MSBuildThisFileDirectory)Microsoft.WindowsAppSDK.DeploymentManagerCommon.targets" />
<Import Project="$(MSBuildThisFileDirectory)Microsoft.WindowsAppSDK.DeploymentManager.CS.targets" Condition="'$(WindowsAppSdkDeploymentManagerInitialize)' == 'true'"/>

<ItemGroup>
<Compile Condition="'$(WindowsAppSdkIncludeVersionInfo)'=='true'" Include="$(MSBuildThisFileDirectory)..\include\WindowsAppSDK-VersionInfo.cs" />
</ItemGroup>

</Project>

0 comments on commit 043d811

Please sign in to comment.