Skip to content

Commit 62cf7f1

Browse files
authored
Making verify package method default to the highest version found (#6026)
* Fix on verify packages method * Initializing highest version found to the version being search * Removing match boolean * Using variable instead of winrt call * Using versions to comparisons * Adding singleton lower version package and test * Adding verification for package registering in test * Adding test with multiple singleton versions
1 parent 142b6e7 commit 62cf7f1

13 files changed

+291
-9
lines changed

WindowsAppRuntime.sln

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "StoragePickers", "StoragePi
750750
EndProject
751751
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Deployment.WindowsAppRuntime.Test.SingletonHigherVersion", "test\Deployment\data\WindowsAppRuntime.Test.SingletonHigherVersion\WindowsAppRuntime.Test.SingletonHigherVersion.vcxproj", "{462CF10A-E6B5-4005-8E25-132D1DE589B7}"
752752
EndProject
753+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Deployment.WindowsAppRuntime.Test.SingletonLowerVersion", "test\Deployment\data\WindowsAppRuntime.Test.SingletonLowerVersion\WindowsAppRuntime.Test.SingletonLowerVersion.vcxproj", "{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}"
754+
EndProject
753755
Global
754756
GlobalSection(SolutionConfigurationPlatforms) = preSolution
755757
Debug|Any CPU = Debug|Any CPU
@@ -2644,6 +2646,22 @@ Global
26442646
{462CF10A-E6B5-4005-8E25-132D1DE589B7}.Release|x64.Build.0 = Release|x64
26452647
{462CF10A-E6B5-4005-8E25-132D1DE589B7}.Release|x86.ActiveCfg = Release|Win32
26462648
{462CF10A-E6B5-4005-8E25-132D1DE589B7}.Release|x86.Build.0 = Release|Win32
2649+
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Debug|Any CPU.ActiveCfg = Debug|x64
2650+
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Debug|Any CPU.Build.0 = Debug|x64
2651+
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Debug|ARM64.ActiveCfg = Debug|ARM64
2652+
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Debug|ARM64.Build.0 = Debug|ARM64
2653+
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Debug|x64.ActiveCfg = Debug|x64
2654+
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Debug|x64.Build.0 = Debug|x64
2655+
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Debug|x86.ActiveCfg = Debug|Win32
2656+
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Debug|x86.Build.0 = Debug|Win32
2657+
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Release|Any CPU.ActiveCfg = Release|x64
2658+
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Release|Any CPU.Build.0 = Release|x64
2659+
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Release|ARM64.ActiveCfg = Release|ARM64
2660+
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Release|ARM64.Build.0 = Release|ARM64
2661+
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Release|x64.ActiveCfg = Release|x64
2662+
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Release|x64.Build.0 = Release|x64
2663+
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Release|x86.ActiveCfg = Release|Win32
2664+
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Release|x86.Build.0 = Release|Win32
26472665
EndGlobalSection
26482666
GlobalSection(SolutionProperties) = preSolution
26492667
HideSolutionNode = FALSE
@@ -2871,6 +2889,7 @@ Global
28712889
{346E099B-45E4-FF40-E63D-8B34915223C1} = {8630F7AA-2969-4DC9-8700-9B468C1DC21D}
28722890
{06AA7FD7-36BE-41AC-9008-56919D1612C6} = {3B706C5C-55E0-4B76-BF59-89E20FE46795}
28732891
{462CF10A-E6B5-4005-8E25-132D1DE589B7} = {2B653A15-2482-40E5-9509-C531E69D0749}
2892+
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D} = {2B653A15-2482-40E5-9509-C531E69D0749}
28742893
EndGlobalSection
28752894
GlobalSection(ExtensibilityGlobals) = postSolution
28762895
SolutionGuid = {4B3D7591-CFEC-4762-9A07-ABE99938FB77}

dev/Deployment/DeploymentManager.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@ namespace winrt::Microsoft::Windows::ApplicationModel::WindowsAppRuntime::implem
368368
const std::wstring& packageIdentifier) try
369369
{
370370
auto packageFullNames{ FindPackagesByFamily(packageFamilyName) };
371-
bool match{};
371+
UINT64 highestVersionFound{ 0 }; // There is no package with version 0
372+
std::wstring highestVersionPackageFullName{};
372373
for (const auto& packageFullName : packageFullNames)
373374
{
374375
auto packagePath{ GetPackagePath(packageFullName) };
@@ -378,18 +379,20 @@ namespace winrt::Microsoft::Windows::ApplicationModel::WindowsAppRuntime::implem
378379
}
379380

380381
auto packageId{ AppModel::Identity::PackageIdentity::FromPackageFullName(packageFullName.c_str()) };
381-
if (packageId.Version().Version >= targetVersion.Version)
382+
const auto packageVersion{ packageId.Version().Version };
383+
if (packageVersion > highestVersionFound)
382384
{
383-
match = true;
384-
if (packageId.Version().Version > targetVersion.Version)
385-
{
386-
g_existingTargetPackagesIfHigherVersion.insert(std::make_pair(packageIdentifier, packageFullName));
387-
}
388-
break;
385+
highestVersionFound = packageVersion;
386+
highestVersionPackageFullName = packageFullName;
389387
}
390388
}
391389

392-
RETURN_HR_IF(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), !match);
390+
if (highestVersionFound > targetVersion.Version)
391+
{
392+
g_existingTargetPackagesIfHigherVersion[packageIdentifier] = highestVersionPackageFullName;
393+
}
394+
395+
RETURN_HR_IF(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), highestVersionFound < targetVersion.Version);
393396
return S_OK;
394397
}
395398
CATCH_RETURN()

test/Deployment/API/APITests.cpp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ namespace Test::Deployment
4141
{
4242
TP::RemovePackage_DeploymentWindowsAppRuntimeSingletonHigherVersion();
4343
TP::RemovePackage_DeploymentWindowsAppRuntimeSingleton();
44+
TP::RemovePackage_DeploymentWindowsAppRuntimeSingletonLowerVersion();
4445
TP::RemovePackage_DeploymentWindowsAppRuntimeMain();
4546
TP::RemovePackage_DeploymentWindowsAppRuntimeFramework();
4647
TP::RemovePackage_WindowsAppRuntimeFramework();
@@ -190,6 +191,36 @@ namespace Test::Deployment
190191
return;
191192
}
192193

194+
TEST_METHOD(Initialize_LowerSingletonVersionPresent)
195+
{
196+
BEGIN_TEST_METHOD_PROPERTIES()
197+
TEST_METHOD_PROPERTY(L"RunAs", L"UAP")
198+
TEST_METHOD_PROPERTY(L"UAP:AppxManifest", L"Deployment-Capabilities-AppxManifest.xml")
199+
END_TEST_METHOD_PROPERTIES();
200+
201+
// Add only the lower version singleton package externally to the API (e.g. the installer).
202+
TP::AddPackage_DeploymentWindowsAppRuntimeSingletonLowerVersion();
203+
VERIFY_IS_TRUE(TP::IsPackageRegistered_DeploymentWindowsAppRuntimeSingletonLowerVersion());
204+
205+
// Verify package status is by default not OK.
206+
auto result{ DeploymentManager::GetStatus() };
207+
Log::Comment(WEX::Common::String().Format(L"Status: 0x%0X", result.ExtendedError().value));
208+
VERIFY_IS_TRUE(result.Status() == DeploymentStatus::PackageInstallRequired);
209+
210+
// Call Initialize to correct and check status again.
211+
result = DeploymentManager::Initialize();
212+
Log::Comment(WEX::Common::String().Format(L"Initialize: 0x%0X", result.ExtendedError().value));
213+
VERIFY_IS_TRUE(result.Status() == DeploymentStatus::Ok);
214+
215+
result = DeploymentManager::GetStatus();
216+
Log::Comment(WEX::Common::String().Format(L"Status: 0x%0X", result.ExtendedError().value));
217+
VERIFY_IS_TRUE(result.Status() == DeploymentStatus::Ok);
218+
219+
VERIFY_IS_FALSE(TP::IsPackageRegistered_DeploymentWindowsAppRuntimeSingletonLowerVersion());
220+
VERIFY_IS_TRUE(TP::IsPackageRegistered_DeploymentWindowsAppRuntimeSingleton());
221+
return;
222+
}
223+
193224
TEST_METHOD(Initialize_HigherSingletonVersionPresent)
194225
{
195226
BEGIN_TEST_METHOD_PROPERTIES()
@@ -214,6 +245,33 @@ namespace Test::Deployment
214245
return;
215246
}
216247

248+
TEST_METHOD(Initialize_MultipleVersionPresent_GetsHighest)
249+
{
250+
BEGIN_TEST_METHOD_PROPERTIES()
251+
TEST_METHOD_PROPERTY(L"RunAs", L"UAP")
252+
TEST_METHOD_PROPERTY(L"UAP:AppxManifest", L"Deployment-Capabilities-AppxManifest.xml")
253+
END_TEST_METHOD_PROPERTIES();
254+
255+
// Add both the lower and higher version singleton packages externally to the API (e.g. the installer).
256+
TP::AddPackage_DeploymentWindowsAppRuntimeSingletonLowerVersion();
257+
TP::AddPackage_DeploymentWindowsAppRuntimeSingleton();
258+
TP::AddPackage_DeploymentWindowsAppRuntimeSingletonHigherVersion();
259+
260+
// Call Initialize to correct and check status again.
261+
auto result = DeploymentManager::Initialize();
262+
Log::Comment(WEX::Common::String().Format(L"Initialize: 0x%0X", result.ExtendedError().value));
263+
VERIFY_IS_TRUE(result.Status() == DeploymentStatus::Ok);
264+
265+
result = DeploymentManager::GetStatus();
266+
Log::Comment(WEX::Common::String().Format(L"Status: 0x%0X", result.ExtendedError().value));
267+
VERIFY_IS_TRUE(result.Status() == DeploymentStatus::Ok);
268+
269+
VERIFY_IS_FALSE(TP::IsPackageRegistered_DeploymentWindowsAppRuntimeSingletonLowerVersion());
270+
VERIFY_IS_FALSE(TP::IsPackageRegistered_DeploymentWindowsAppRuntimeSingleton());
271+
VERIFY_IS_TRUE(TP::IsPackageRegistered_DeploymentWindowsAppRuntimeSingletonHigherVersion());
272+
return;
273+
}
274+
217275
TEST_METHOD(Initialize_NoCapabilities)
218276
{
219277
BEGIN_TEST_METHOD_PROPERTIES()

test/Deployment/API/DeploymentTests.vcxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@
225225
<ProjectReference Include="$(RepoRoot)\test\Deployment\data\WindowsAppRuntime.Test.SingletonHigherVersion\WindowsAppRuntime.Test.SingletonHigherVersion.vcxproj">
226226
<Project>{462cf10a-e6b5-4005-8e25-132d1de589b7}</Project>
227227
</ProjectReference>
228+
<ProjectReference Include="$(RepoRoot)\test\Deployment\data\WindowsAppRuntime.Test.SingletonLowerVersion\WindowsAppRuntime.Test.SingletonLowerVersion.vcxproj">
229+
<Project>{7a3c8f5d-9b2e-4a1f-8d6c-3e9f7b4a2c1d}</Project>
230+
</ProjectReference>
228231
</ItemGroup>
229232
<ItemGroup>
230233
<CopyFileToFolders Include="$(MSBuildThisFileDirectory)Deployment-Capabilities-AppxManifest.xml" DestinationFolders="$(TargetDir)" TreatOutputAsContent="true" />
91.2 KB
Loading
11.4 KB
Loading
3.91 KB
Loading
11.8 KB
Loading
4.33 KB
Loading
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
<ProjectConfiguration Include="Debug|ARM64">
21+
<Configuration>Debug</Configuration>
22+
<Platform>ARM64</Platform>
23+
</ProjectConfiguration>
24+
<ProjectConfiguration Include="Release|ARM64">
25+
<Configuration>Release</Configuration>
26+
<Platform>ARM64</Platform>
27+
</ProjectConfiguration>
28+
</ItemGroup>
29+
<PropertyGroup Label="Globals">
30+
<VCProjectVersion>16.0</VCProjectVersion>
31+
<ProjectGuid>{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}</ProjectGuid>
32+
<Keyword>Win32Proj</Keyword>
33+
<ProjectName>Deployment.WindowsAppRuntime.Test.SingletonLowerVersion</ProjectName>
34+
</PropertyGroup>
35+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
36+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
37+
<ConfigurationType>Makefile</ConfigurationType>
38+
<UseDebugLibraries>true</UseDebugLibraries>
39+
<PlatformToolset>v143</PlatformToolset>
40+
</PropertyGroup>
41+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
42+
<ConfigurationType>Makefile</ConfigurationType>
43+
<UseDebugLibraries>false</UseDebugLibraries>
44+
<PlatformToolset>v143</PlatformToolset>
45+
</PropertyGroup>
46+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
47+
<ConfigurationType>Makefile</ConfigurationType>
48+
<UseDebugLibraries>true</UseDebugLibraries>
49+
<PlatformToolset>v143</PlatformToolset>
50+
</PropertyGroup>
51+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
52+
<ConfigurationType>Makefile</ConfigurationType>
53+
<UseDebugLibraries>false</UseDebugLibraries>
54+
<PlatformToolset>v143</PlatformToolset>
55+
</PropertyGroup>
56+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
57+
<ConfigurationType>Makefile</ConfigurationType>
58+
<UseDebugLibraries>true</UseDebugLibraries>
59+
<PlatformToolset>v143</PlatformToolset>
60+
</PropertyGroup>
61+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
62+
<ConfigurationType>Makefile</ConfigurationType>
63+
<UseDebugLibraries>false</UseDebugLibraries>
64+
<PlatformToolset>v143</PlatformToolset>
65+
</PropertyGroup>
66+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
67+
<ImportGroup Label="ExtensionSettings">
68+
</ImportGroup>
69+
<ImportGroup Label="Shared">
70+
</ImportGroup>
71+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
72+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
73+
</ImportGroup>
74+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
75+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
76+
</ImportGroup>
77+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
78+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
79+
</ImportGroup>
80+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
81+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
82+
</ImportGroup>
83+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
84+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
85+
</ImportGroup>
86+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
87+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
88+
</ImportGroup>
89+
<PropertyGroup Label="UserMacros" />
90+
<PropertyGroup>
91+
<PreNMakeBuildTarget>$(PostBuildDependsOn);MakeMSIX</PreNMakeBuildTarget>
92+
<NMakeBuildCommandLine>REM Nothing to do!</NMakeBuildCommandLine>
93+
<NMakeReBuildCommandLine>REM TODO Clean then Build</NMakeReBuildCommandLine>
94+
<NMakeCleanCommandLine>REM TODO Clean</NMakeCleanCommandLine>
95+
96+
<MakeMsixOutputFilename>Deployment.WindowsAppRuntime.Test.SingletonLowerVersion.msix</MakeMsixOutputFilename>
97+
</PropertyGroup>
98+
<ItemGroup>
99+
<MakeMsixInputAssets Include="$(MSBuildThisFileDirectory)\Assets\*" />
100+
<MakeMsixInputs Include="$(MSBuildThisFileDirectory)appxmanifest.xml" />
101+
</ItemGroup>
102+
<PropertyGroup>
103+
<PackageCertificateKeyFile>$(RepoTestCertificatePFX)</PackageCertificateKeyFile>
104+
<PackageCertificatePassword>$(RepoTestCertificatePassword)</PackageCertificatePassword>
105+
</PropertyGroup>
106+
<Import Project="$(RepoRoot)\MakeMsix.targets" />
107+
<ItemGroup>
108+
<Xml Include="appxmanifest.xml" />
109+
</ItemGroup>
110+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
111+
<ImportGroup Label="ExtensionTargets">
112+
</ImportGroup>
113+
</Project>

0 commit comments

Comments
 (0)