Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions WindowsAppRuntime.sln
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "StoragePickers", "StoragePi
EndProject
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}"
EndProject
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}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -2644,6 +2646,22 @@ Global
{462CF10A-E6B5-4005-8E25-132D1DE589B7}.Release|x64.Build.0 = Release|x64
{462CF10A-E6B5-4005-8E25-132D1DE589B7}.Release|x86.ActiveCfg = Release|Win32
{462CF10A-E6B5-4005-8E25-132D1DE589B7}.Release|x86.Build.0 = Release|Win32
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Debug|Any CPU.ActiveCfg = Debug|x64
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Debug|Any CPU.Build.0 = Debug|x64
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Debug|ARM64.ActiveCfg = Debug|ARM64
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Debug|ARM64.Build.0 = Debug|ARM64
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Debug|x64.ActiveCfg = Debug|x64
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Debug|x64.Build.0 = Debug|x64
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Debug|x86.ActiveCfg = Debug|Win32
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Debug|x86.Build.0 = Debug|Win32
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Release|Any CPU.ActiveCfg = Release|x64
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Release|Any CPU.Build.0 = Release|x64
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Release|ARM64.ActiveCfg = Release|ARM64
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Release|ARM64.Build.0 = Release|ARM64
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Release|x64.ActiveCfg = Release|x64
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Release|x64.Build.0 = Release|x64
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Release|x86.ActiveCfg = Release|Win32
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -2871,6 +2889,7 @@ Global
{346E099B-45E4-FF40-E63D-8B34915223C1} = {8630F7AA-2969-4DC9-8700-9B468C1DC21D}
{06AA7FD7-36BE-41AC-9008-56919D1612C6} = {3B706C5C-55E0-4B76-BF59-89E20FE46795}
{462CF10A-E6B5-4005-8E25-132D1DE589B7} = {2B653A15-2482-40E5-9509-C531E69D0749}
{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D} = {2B653A15-2482-40E5-9509-C531E69D0749}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4B3D7591-CFEC-4762-9A07-ABE99938FB77}
Expand Down
21 changes: 12 additions & 9 deletions dev/Deployment/DeploymentManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,8 @@ namespace winrt::Microsoft::Windows::ApplicationModel::WindowsAppRuntime::implem
const std::wstring& packageIdentifier) try
{
auto packageFullNames{ FindPackagesByFamily(packageFamilyName) };
bool match{};
UINT64 highestVersionFound{ 0 }; // There is no package with version 0
std::wstring highestVersionPackageFullName{};
for (const auto& packageFullName : packageFullNames)
{
auto packagePath{ GetPackagePath(packageFullName) };
Expand All @@ -378,18 +379,20 @@ namespace winrt::Microsoft::Windows::ApplicationModel::WindowsAppRuntime::implem
}

auto packageId{ AppModel::Identity::PackageIdentity::FromPackageFullName(packageFullName.c_str()) };
if (packageId.Version().Version >= targetVersion.Version)
const auto packageVersion{ packageId.Version().Version };
if (packageVersion > highestVersionFound)
{
match = true;
if (packageId.Version().Version > targetVersion.Version)
{
g_existingTargetPackagesIfHigherVersion.insert(std::make_pair(packageIdentifier, packageFullName));
}
break;
highestVersionFound = packageVersion;
highestVersionPackageFullName = packageFullName;
}
}

RETURN_HR_IF(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), !match);
if (highestVersionFound > targetVersion.Version)
{
g_existingTargetPackagesIfHigherVersion[packageIdentifier] = highestVersionPackageFullName;
}

RETURN_HR_IF(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), highestVersionFound < targetVersion.Version);
return S_OK;
}
CATCH_RETURN()
Expand Down
58 changes: 58 additions & 0 deletions test/Deployment/API/APITests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ namespace Test::Deployment
{
TP::RemovePackage_DeploymentWindowsAppRuntimeSingletonHigherVersion();
TP::RemovePackage_DeploymentWindowsAppRuntimeSingleton();
TP::RemovePackage_DeploymentWindowsAppRuntimeSingletonLowerVersion();
TP::RemovePackage_DeploymentWindowsAppRuntimeMain();
TP::RemovePackage_DeploymentWindowsAppRuntimeFramework();
TP::RemovePackage_WindowsAppRuntimeFramework();
Expand Down Expand Up @@ -190,6 +191,36 @@ namespace Test::Deployment
return;
}

TEST_METHOD(Initialize_LowerSingletonVersionPresent)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_METHOD_PROPERTY(L"RunAs", L"UAP")
TEST_METHOD_PROPERTY(L"UAP:AppxManifest", L"Deployment-Capabilities-AppxManifest.xml")
END_TEST_METHOD_PROPERTIES();

// Add only the lower version singleton package externally to the API (e.g. the installer).
TP::AddPackage_DeploymentWindowsAppRuntimeSingletonLowerVersion();
VERIFY_IS_TRUE(TP::IsPackageRegistered_DeploymentWindowsAppRuntimeSingletonLowerVersion());

// Verify package status is by default not OK.
auto result{ DeploymentManager::GetStatus() };
Log::Comment(WEX::Common::String().Format(L"Status: 0x%0X", result.ExtendedError().value));
VERIFY_IS_TRUE(result.Status() == DeploymentStatus::PackageInstallRequired);

// Call Initialize to correct and check status again.
result = DeploymentManager::Initialize();
Log::Comment(WEX::Common::String().Format(L"Initialize: 0x%0X", result.ExtendedError().value));
VERIFY_IS_TRUE(result.Status() == DeploymentStatus::Ok);

result = DeploymentManager::GetStatus();
Log::Comment(WEX::Common::String().Format(L"Status: 0x%0X", result.ExtendedError().value));
VERIFY_IS_TRUE(result.Status() == DeploymentStatus::Ok);

VERIFY_IS_FALSE(TP::IsPackageRegistered_DeploymentWindowsAppRuntimeSingletonLowerVersion());
VERIFY_IS_TRUE(TP::IsPackageRegistered_DeploymentWindowsAppRuntimeSingleton());
return;
}

TEST_METHOD(Initialize_HigherSingletonVersionPresent)
{
BEGIN_TEST_METHOD_PROPERTIES()
Expand All @@ -214,6 +245,33 @@ namespace Test::Deployment
return;
}

TEST_METHOD(Initialize_MultipleVersionPresent_GetsHighest)
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_METHOD_PROPERTY(L"RunAs", L"UAP")
TEST_METHOD_PROPERTY(L"UAP:AppxManifest", L"Deployment-Capabilities-AppxManifest.xml")
END_TEST_METHOD_PROPERTIES();

// Add both the lower and higher version singleton packages externally to the API (e.g. the installer).
TP::AddPackage_DeploymentWindowsAppRuntimeSingletonLowerVersion();
TP::AddPackage_DeploymentWindowsAppRuntimeSingleton();
TP::AddPackage_DeploymentWindowsAppRuntimeSingletonHigherVersion();

// Call Initialize to correct and check status again.
auto result = DeploymentManager::Initialize();
Log::Comment(WEX::Common::String().Format(L"Initialize: 0x%0X", result.ExtendedError().value));
VERIFY_IS_TRUE(result.Status() == DeploymentStatus::Ok);

result = DeploymentManager::GetStatus();
Log::Comment(WEX::Common::String().Format(L"Status: 0x%0X", result.ExtendedError().value));
VERIFY_IS_TRUE(result.Status() == DeploymentStatus::Ok);

VERIFY_IS_FALSE(TP::IsPackageRegistered_DeploymentWindowsAppRuntimeSingletonLowerVersion());
VERIFY_IS_FALSE(TP::IsPackageRegistered_DeploymentWindowsAppRuntimeSingleton());
VERIFY_IS_TRUE(TP::IsPackageRegistered_DeploymentWindowsAppRuntimeSingletonHigherVersion());
return;
}

TEST_METHOD(Initialize_NoCapabilities)
{
BEGIN_TEST_METHOD_PROPERTIES()
Expand Down
3 changes: 3 additions & 0 deletions test/Deployment/API/DeploymentTests.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@
<ProjectReference Include="$(RepoRoot)\test\Deployment\data\WindowsAppRuntime.Test.SingletonHigherVersion\WindowsAppRuntime.Test.SingletonHigherVersion.vcxproj">
<Project>{462cf10a-e6b5-4005-8e25-132d1de589b7}</Project>
</ProjectReference>
<ProjectReference Include="$(RepoRoot)\test\Deployment\data\WindowsAppRuntime.Test.SingletonLowerVersion\WindowsAppRuntime.Test.SingletonLowerVersion.vcxproj">
<Project>{7a3c8f5d-9b2e-4a1f-8d6c-3e9f7b4a2c1d}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<CopyFileToFolders Include="$(MSBuildThisFileDirectory)Deployment-Capabilities-AppxManifest.xml" DestinationFolders="$(TargetDir)" TreatOutputAsContent="true" />
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<ProjectGuid>{7A3C8F5D-9B2E-4A1F-8D6C-3E9F7B4A2C1D}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<ProjectName>Deployment.WindowsAppRuntime.Test.SingletonLowerVersion</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<PreNMakeBuildTarget>$(PostBuildDependsOn);MakeMSIX</PreNMakeBuildTarget>
<NMakeBuildCommandLine>REM Nothing to do!</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>REM TODO Clean then Build</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>REM TODO Clean</NMakeCleanCommandLine>

<MakeMsixOutputFilename>Deployment.WindowsAppRuntime.Test.SingletonLowerVersion.msix</MakeMsixOutputFilename>
</PropertyGroup>
<ItemGroup>
<MakeMsixInputAssets Include="$(MSBuildThisFileDirectory)\Assets\*" />
<MakeMsixInputs Include="$(MSBuildThisFileDirectory)appxmanifest.xml" />
</ItemGroup>
<PropertyGroup>
<PackageCertificateKeyFile>$(RepoTestCertificatePFX)</PackageCertificateKeyFile>
<PackageCertificatePassword>$(RepoTestCertificatePassword)</PackageCertificatePassword>
</PropertyGroup>
<Import Project="$(RepoRoot)\MakeMsix.targets" />
<ItemGroup>
<Xml Include="appxmanifest.xml" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Xml Include="appxmanifest.xml" />
</ItemGroup>
<ItemGroup>
<None Include="Makefile.mak" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>

<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
xmlns:com="http://schemas.microsoft.com/appx/manifest/com/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap uap3 uap5 com rescap">

<Identity
Name="MicrosoftCorporationII.WinAppRuntime.Singleton-T"
Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
Version="4.1.1966.333" />

<Properties>
<DisplayName>MicrosoftCorporationII.WinAppRuntime.Singleton.Test (aka Microsoft.WindowsAppRuntime.Singleton) fake for tests</DisplayName>
<PublisherDisplayName>Microsoft Corporation</PublisherDisplayName>
<Logo>Assets\logo.png</Logo>
</Properties>

<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
<PackageDependency Name="Microsoft.WindowsAppRuntime.1.0-Test" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" MinVersion="0.0.0.0"/>
</Dependencies>

<Resources>
<Resource Language="en"/>
</Resources>

<Capabilities>
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>
Loading
Loading