Skip to content

Commit e269e4b

Browse files
authored
Merge pull request #45 from cwillisf/windows-package-version
fix(win): apply the calculated version number to packaging output
2 parents 3954027 + 57a6ebc commit e269e4b

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

SharedProps/ScratchVersion.targets

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ This file sets up version properties in our own Scratch way.
3737
<Message Text="ScratchVersionFull = $(ScratchVersionFull)" />
3838
<Message Text="ScratchVersionHash = $(ScratchVersionHash)" />
3939
<Message Text="ScratchVersionDetail = $(ScratchVersionDetail)" />
40+
<Message Text="ScratchVersionBuildNumber = $(ScratchVersionBuildNumber)" />
41+
<Message Text="ScratchVersionQuad = $(ScratchVersionQuad)" />
4042
<Message Text="ScratchVersionBuildTime = $(ScratchVersionBuildTime)" />
4143
</Target>
4244
</Project>

scratch-link-win-msix/scratch-link-win-msix.wapproj

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,37 @@
101101
<PublishProfile>Properties\PublishProfiles\win10-$(Platform).pubxml</PublishProfile>
102102
</ProjectReference>
103103
</ItemGroup>
104+
<ItemGroup>
105+
<PackageReference Include="GitInfo" Version="2.3.0" />
106+
</ItemGroup>
104107
<Import Project="$(SolutionDir)SharedProps\WindowsSDK.props" />
105108
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.targets" />
106-
</Project>
109+
<Import Project="$(SolutionDir)SharedProps\ScratchVersion.targets" />
110+
<Target Name="ScratchModifyAppxManifest" BeforeTargets="_ValidatePresenceOfAppxManifestItems" DependsOnTargets="ScratchVersion">
111+
<Copy SourceFiles="@(AppxManifest)" DestinationFolder="$(IntermediateOutputPath)" />
112+
<!-- Do a three-step swap to replace @AppxManifest with a version prefixed with the intermediate path -->
113+
<!-- Note that '%' in MSBuild-speak causes a "for each"-style iteration -->
114+
<!-- @(AppxManifest) should only ever have 1 item, but it's a list so we have to treat it that way -->
115+
<ItemGroup>
116+
<!-- Make a new prefixed item in a temporary list -->
117+
<_ScratchAppxManifest Include="$(IntermediateOutputPath)%(AppxManifest.Identity)" />
118+
<!-- Remove the old un-prefixed item from the original list -->
119+
<AppxManifest Remove="%(AppxManifest.Identity)" />
120+
<!-- Add the item from the temporary list into the official list -->
121+
<AppxManifest Include="%(_ScratchAppxManifest.Identity)" />
122+
</ItemGroup>
123+
<PropertyGroup>
124+
<!-- XmlPoke doesn't support implicit namespacing -->
125+
<_ScratchAppxManifestNamespaces>
126+
<Namespace Prefix="am" Uri="http://schemas.microsoft.com/appx/manifest/foundation/windows10" />
127+
</_ScratchAppxManifestNamespaces>
128+
</PropertyGroup>
129+
<!-- Inject the correct version into the XML file in the intermediate path -->
130+
<XmlPoke
131+
XmlInputPath="%(AppxManifest.Identity)"
132+
Query="/am:Package/am:Identity/@Version"
133+
Value="$(ScratchVersionQuad)"
134+
Namespaces="$(_ScratchAppxManifestNamespaces)"
135+
/>
136+
</Target>
137+
</Project>

0 commit comments

Comments
 (0)