简体   繁体   中英

UWP .appx file naming

I am building an UWP app and I want to have generated package to be named with the build number in order to distinguish the builds. So far, I have this configuration in the csproj file:

  <Target Name="BeforeBuild">
    <Message Text="Updating AssemblyInfo to Version $(VersionNumber)"></Message>
    <Message Text="Writing to AssemblyInfo files in $(SolutionRoot)"></Message>

    <AssemblyInfo CodeLanguage="CS"
             AssemblyCompany="Company"
             AssemblyProduct="Product"
             AssemblyCopyright="Copyright © Company 2011"
             ComVisible="true"
             AssemblyVersion="$(BUILD_NUMBER)"
             AssemblyFileVersion="$(BUILD_NUMBER)" />   
  </Target>

All good, I can run the msbuild with the /p:BUILD_NUMBER=1.2.3.4 argument, but this is only reflecting in AssemblyInfo.cs file. The .appx file will be named as MyApplication.Core_1.0.0.0_x86_Test.appx and not MyApplication.Core_1.2.3.4_x86_Test.appx

How can I use the BUILD_NUMBER information to be reflected in the .appx file name?

The version number in .appx file name is not set by AssemblyInfo . This version number is called Package version number which is set as a value in the Version attribute of the Package/Identity element in the app manifest like:

<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
  <Identity Name="e12578ad-9b81-44bb-8651-0b58e44e71b8" Publisher="CN=Jay Zuo" Version="1.2.3.0" />
  ...
</Package>

Once you changed the Version attribute and then run MSBuild , you will get the .appx file named like MyUWPApp_1.2.3.0_x86.appx .

Besides this, we usually change the package version number while creating an app package . This can be done with Microsoft Visual Studio wizard like following:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM