Skip to content

Instantly share code, notes, and snippets.

@htuomola
Last active December 21, 2015 12:59
Show Gist options
  • Save htuomola/4434914 to your computer and use it in GitHub Desktop.
Save htuomola/4434914 to your computer and use it in GitHub Desktop.
MsBuild target to rename Windows Phone XAP packages after building to include build configuration & assembly version number. Note that as far as I know, it's not possible to delete the original XAP file as it is required for emulator deployment & debugging.
<Target Name="AfterBuild">
<GetAssemblyIdentity AssemblyFiles="$(OutputPath)\$(AssemblyName).dll">
<Output TaskParameter="Assemblies" ItemName="MyAssemblyIdentities" />
</GetAssemblyIdentity>
<PropertyGroup>
<XapFilenameWithoutExt>$(XapFilename.Replace('.xap',''))</XapFilenameWithoutExt>
<OutputXapFilename>$(XapFilenameWithoutExt)_$(Configuration)_%(MyAssemblyIdentities.Version).xap</OutputXapFilename>
</PropertyGroup>
<Message Text="Removing all files matching with '$(XapFilenameWithoutExt)_*.xap'" />
<ItemGroup>
<OldXapFiles Include="$(OutputPath)\$(XapFilenameWithoutExt)_*.xap" />
</ItemGroup>
<Delete Files="@(OldXapFiles)" />
<Copy SourceFiles="$(OutputPath)\$(XapFilename)" DestinationFiles="$(OutputPath)\$(OutputXapFilename)" />
</Target>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment