Have Datetime as part of version string while creating MSIX package

Elangovan Manickam 0 Reputation points
2023-05-30T20:19:31.54+00:00

I have a .NET MAUI app and I'm able to create MSIX installer. I want to add the datetime as suffix to the version number when the MSIX is created. for example, MauiPublishTest_1.0.0.15_x64.msix is the file name I get and I would like to get something like MauiPublishTest_1.0.0.2023053023_x64.msix where the last part is a datetime. As I understand from the Microsoft docs that the values are integer and it should have 4 parts, but I still hope to find some answers that uses the datetime(or UTC timestamp) as part of the version.

Following code snippet shows how currently it is setup in the .csproj of my maui project.

<!-- Versions -->
<ApplicationDisplayVersion>1.0.1</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>

https://truegeek.com/2022/09/13/automate-build-number-in-maui/

based on the above link, I tried to use the datetime in the ApplicationVersion as shown in following code snippet.

		<VersionPrefix>7.0.0</VersionPrefix>
		<VersionSuffix>mysamplesuffix</VersionSuffix>
		<ApplicationDisplayVersion>1.0.3</ApplicationDisplayVersion>
		<ApplicationVersion>$([System.DateTime]::Now.ToString('yyyyMMddHH'))</ApplicationVersion>

and I run the following command

dotnet publish -f net7.0-windows10.0.19041.0 -c Release -p:RuntimeIdentifierOverride=win10-x64 -r win10-x64 --sc true -p:AppxPackageDir=publish\windows\ --version-suffix "ci-1234"

I get the following error.

MakeAppx : error : Error info: error C00CE169: App manifest validation error: The app manifest must be valid as per schema: Line 10, Column 82, Reason: '1.0.3.2023053016' violates pattern constraint of '(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|
6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])(\.(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])){3}'. [D:\Projects\VisualStudio\MauiPublishTest\MauiPublishTest\MauiPublishTest.csproj::T
argetFramework=net7.0-windows10.0.19041.0]
MakeAppx : error : Package creation failed. [D:\Projects\VisualStudio\MauiPublishTest\MauiPublishTest\MauiPublishTest.csproj::TargetFramework=net7.0-windows10.0.19041.0]
MakeAppx : error : 0x80080204 - The specified package format is not valid: The package manifest is not valid. [D:\Projects\VisualStudio\MauiPublishTest\MauiPublishTest\MauiPublishTest.csproj::TargetFramework=net7.0-windows10.0.19041.0]

can anyone help in throw some light on how to get the datetime part of the version.

Another thing I noted is, the VersionPrefix and VersionSuffix is ignored completely from .csproj and also from the command line.

Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
750 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,221 questions
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
37,735 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 29,301 Reputation points Microsoft Vendor
    2023-06-01T08:46:53.69+00:00

    Hello,

    The VersionPrefix and VersionSuffix are for .NET not MSIX, so they cannot be included. And you cannot have Datetime as part of version string in MSIX package.

    As the regular expression in the error message suggests, you can't have every field higher than 65535, the MSIX manifest schema doesn't allow numbers of that size you convert from Datetime.

    In addition, Maui doesn't affect the allowed version schemas. Those are set by the underlying platform. For Windows, Maui uses the Windows App SDK / WinUI3, which in turn uses MSIX for packaging.

    For more details, please see Package version numbering.

    For Windows 10 or Windows 11 (UWP) packages, the last (fourth) section of the version number is reserved for Store use and must be left as 0 when you build your package (although the Store may change the value in this section). The other sections must be set to an integer between 0 and 65535 (except for the first section, which cannot be 0).

    Best Regards,

    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments