@@ -75,6 +75,21 @@ namespace winrt::Microsoft::Windows::ApplicationModel::WindowsAppRuntime::implem
7575 return Initialize (GetCurrentFrameworkPackageFullName (), options, true );
7676 }
7777
78+ std::wstring ExtractFormattedVersionTag (const std::wstring& versionTag)
79+ {
80+ std::wstring result{};
81+ if (versionTag.size () > 1 )
82+ {
83+ result = std::wstring (L" -" ) + versionTag[1 ];
84+ }
85+ unsigned int numberBeforeUnderscore{};
86+ if (swscanf_s (versionTag.c_str (), L" %*[^0-9]%u" , &numberBeforeUnderscore) == 1 )
87+ {
88+ result += std::to_wstring (numberBeforeUnderscore);
89+ }
90+ return result;
91+ }
92+
7893 winrt::Microsoft::Windows::ApplicationModel::WindowsAppRuntime::DeploymentResult DeploymentManager::GetStatus (hstring const & packageFullName)
7994 {
8095 // Get PackageInfo for WinAppSDK framework package
@@ -113,24 +128,42 @@ namespace winrt::Microsoft::Windows::ApplicationModel::WindowsAppRuntime::implem
113128 {
114129 // Build package family name based on the framework naming scheme.
115130 std::wstring packageFamilyName{};
131+ // The main and singleton packages contain a shortened version tag for the package family name.
132+ std::wstring formattedVersionTag{};
133+
134+ // PackageFamilyName = Prefix + Subtypename + VersionTag + Suffix
135+ // On WindowsAppSDK 1.1+, Main and Singleton packages are sharing same Package Name Prefix.
116136 if (package.versionType == PackageVersionType::Versioned)
117137 {
118- // PackageFamilyName = Prefix + SubTypeName + VersionIdentifier + Suffix
119- // On WindowsAppSDK 1.1+, Main and Singleton packages are sharing same Package Name Prefix.
120- packageFamilyName = WINDOWSAPPRUNTIME_PACKAGE_NAME_MAINPREFIX WINDOWSAPPRUNTIME_PACKAGE_SUBTYPENAME_DELIMETER + package.identifier + packageNameVersionIdentifier + WINDOWSAPPRUNTIME_PACKAGE_NAME_SUFFIX;
138+ // To understand the package naming of main and singleton packages, see https://github.com/microsoft/WindowsAppSDK/blob/main/specs/Deployment/MSIXPackages.md#3-package-naming
139+ if (!packageNameVersionTag.empty ())
140+ {
141+ formattedVersionTag = packageNameVersionIdentifier.substr (0 , versionTagPos) + ExtractFormattedVersionTag (packageNameVersionTag);
142+ }
143+ else
144+ {
145+ formattedVersionTag = packageNameVersionIdentifier.substr (0 , versionTagPos); // "1.8"
146+ }
121147 }
122148 else if (package.versionType == PackageVersionType::Unversioned)
123149 {
124- // PackageFamilyName = Prefix + Subtypename + VersionTag + Suffix
125- // On WindowsAppSDK 1.1+, Main and Singleton packages are sharing same Package Name Prefix.
126- packageFamilyName = WINDOWSAPPRUNTIME_PACKAGE_NAME_MAINPREFIX WINDOWSAPPRUNTIME_PACKAGE_SUBTYPENAME_DELIMETER + package.identifier + packageNameVersionTag + WINDOWSAPPRUNTIME_PACKAGE_NAME_SUFFIX;
150+ if (!packageNameVersionTag.empty ())
151+ {
152+ formattedVersionTag = ExtractFormattedVersionTag (packageNameVersionTag);
153+ }
154+ else
155+ {
156+ formattedVersionTag = L" " ;
157+ }
127158 }
128159 else
129160 {
130161 // Other version types not supported.
131- FAIL_FAST_HR (HRESULT_FROM_WIN32 (ERROR_UNSUPPORTED_TYPE));
162+ THROW_HR_MSG (HRESULT_FROM_WIN32 (ERROR_UNSUPPORTED_TYPE), " %d " , static_cast < int >(package. versionType ));
132163 }
133164
165+ packageFamilyName = std::format (WINDOWSAPPRUNTIME_PACKAGE_NAME_MAINPREFIX WINDOWSAPPRUNTIME_PACKAGE_SUBTYPENAME_DELIMETER L" {}{}" WINDOWSAPPRUNTIME_PACKAGE_NAME_SUFFIX, package.identifier , formattedVersionTag);
166+
134167 // Get target version based on the framework.
135168 auto targetPackageVersion{ frameworkPackageInfo.Package (0 ).packageId .version };
136169
0 commit comments