Initial creation of the standalone Project Reunion Installer (#444)

* Initial creation of the standalone Project Reunion Installer

* Add tests and PR feedback

Adds tests and changes from PR feedback.

* PR Feedback updates

* Additional PR Feedback updates

* Update exception handling

Moved code to be exception-based and caught at the highest layer of install.

* move and rename solution paths, add test packages

Refactored the test package generation into a separate solution to be run when needed to generate test packages, and added the test packages, which are small and do not need to be built every time for easier testing and faster building. Also moved the installer up a level as it is a separate set of solutions and not part of the main reunion solution and following same naming patterns.

* Fix a few nits in install.h

* Remove old renamed file

help.* was renamed to console.*, removing obsolete version.

* Fix some nits
This commit is contained in:
David Bennett 2021-03-04 13:33:47 -08:00 коммит произвёл GitHub
Родитель cc1914abe2
Коммит 38d2414388
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
39 изменённых файлов: 1662 добавлений и 1 удалений

8
.gitignore поставляемый
Просмотреть файл

@ -327,7 +327,13 @@ __pycache__/
BuildOutput/
.nuget/
# Installer build configuration header
installer/dev/project_reunion_definitions_override.h
# Installer test packages
!installer/test/testpackages/
# Project Reunion specific files
Microsoft.WinUI.AppX.targets
dev/vsix/extension/LICENSE
!dev/vsix/**/*.pubxml
!dev/vsix/**/*.pubxml

Просмотреть файл

@ -0,0 +1,62 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30804.86
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ProjectReunionInstall", "dev\ProjectReunionInstall.vcxproj", "{E6E59B30-9F55-4550-AA73-3B3B3DC89872}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InstallerFunctionalTests", "test\InstallerFunctionalTests\InstallerFunctionalTests.vcxproj", "{79830E23-FAA6-4C02-A83A-419B68434AA7}"
ProjectSection(ProjectDependencies) = postProject
{E6E59B30-9F55-4550-AA73-3B3B3DC89872} = {E6E59B30-9F55-4550-AA73-3B3B3DC89872}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E6E59B30-9F55-4550-AA73-3B3B3DC89872}.Debug|Any CPU.ActiveCfg = Debug|Win32
{E6E59B30-9F55-4550-AA73-3B3B3DC89872}.Debug|ARM.ActiveCfg = Debug|Win32
{E6E59B30-9F55-4550-AA73-3B3B3DC89872}.Debug|ARM64.ActiveCfg = Debug|Win32
{E6E59B30-9F55-4550-AA73-3B3B3DC89872}.Debug|x64.ActiveCfg = Debug|x64
{E6E59B30-9F55-4550-AA73-3B3B3DC89872}.Debug|x64.Build.0 = Debug|x64
{E6E59B30-9F55-4550-AA73-3B3B3DC89872}.Debug|x86.ActiveCfg = Debug|Win32
{E6E59B30-9F55-4550-AA73-3B3B3DC89872}.Debug|x86.Build.0 = Debug|Win32
{E6E59B30-9F55-4550-AA73-3B3B3DC89872}.Release|Any CPU.ActiveCfg = Release|Win32
{E6E59B30-9F55-4550-AA73-3B3B3DC89872}.Release|ARM.ActiveCfg = Release|Win32
{E6E59B30-9F55-4550-AA73-3B3B3DC89872}.Release|ARM64.ActiveCfg = Release|Win32
{E6E59B30-9F55-4550-AA73-3B3B3DC89872}.Release|x64.ActiveCfg = Release|x64
{E6E59B30-9F55-4550-AA73-3B3B3DC89872}.Release|x64.Build.0 = Release|x64
{E6E59B30-9F55-4550-AA73-3B3B3DC89872}.Release|x86.ActiveCfg = Release|Win32
{E6E59B30-9F55-4550-AA73-3B3B3DC89872}.Release|x86.Build.0 = Release|Win32
{79830E23-FAA6-4C02-A83A-419B68434AA7}.Debug|Any CPU.ActiveCfg = Debug|Win32
{79830E23-FAA6-4C02-A83A-419B68434AA7}.Debug|ARM.ActiveCfg = Debug|Win32
{79830E23-FAA6-4C02-A83A-419B68434AA7}.Debug|ARM64.ActiveCfg = Debug|Win32
{79830E23-FAA6-4C02-A83A-419B68434AA7}.Debug|x64.ActiveCfg = Debug|x64
{79830E23-FAA6-4C02-A83A-419B68434AA7}.Debug|x64.Build.0 = Debug|x64
{79830E23-FAA6-4C02-A83A-419B68434AA7}.Debug|x86.ActiveCfg = Debug|Win32
{79830E23-FAA6-4C02-A83A-419B68434AA7}.Debug|x86.Build.0 = Debug|Win32
{79830E23-FAA6-4C02-A83A-419B68434AA7}.Release|Any CPU.ActiveCfg = Release|Win32
{79830E23-FAA6-4C02-A83A-419B68434AA7}.Release|ARM.ActiveCfg = Release|Win32
{79830E23-FAA6-4C02-A83A-419B68434AA7}.Release|ARM64.ActiveCfg = Release|Win32
{79830E23-FAA6-4C02-A83A-419B68434AA7}.Release|x64.ActiveCfg = Release|x64
{79830E23-FAA6-4C02-A83A-419B68434AA7}.Release|x64.Build.0 = Release|x64
{79830E23-FAA6-4C02-A83A-419B68434AA7}.Release|x86.ActiveCfg = Release|Win32
{79830E23-FAA6-4C02-A83A-419B68434AA7}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5557FA31-D9F3-4D4D-9076-970775EB64A1}
EndGlobalSection
EndGlobal

Просмотреть файл

@ -0,0 +1,75 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
/////////////////////////////////////////////////////////////////////////////
//
// PACKAGE
//
#include "project_reunion_definitions.h"
#if defined(PR_FRAMEWORK_X86_RCENTRY)
PR_FRAMEWORK_X86_RCENTRY
#endif
#if defined(PR_FRAMEWORK_X64_RCENTRY)
PR_FRAMEWORK_X64_RCENTRY
#endif
#if defined(PR_FRAMEWORK_ARM64_RCENTRY)
PR_FRAMEWORK_ARM64_RCENTRY
#endif
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
#include "project_reunion_definitions.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

Просмотреть файл

@ -0,0 +1,153 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="16.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.201217.4\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.201217.4\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
<CppWinRTOptimized>true</CppWinRTOptimized>
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
<CppWinRTGenerateWindowsMetadata>true</CppWinRTGenerateWindowsMetadata>
<MinimalCoreWin>true</MinimalCoreWin>
<VCProjectVersion>16.0</VCProjectVersion>
<ProjectGuid>{e6e59b30-9f55-4550-aa73-3b3b3dc89872}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>ProjectReunionInstall</RootNamespace>
<WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0.19041.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformMinVersion>10.0.17763.0</WindowsTargetPlatformMinVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<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>
</ItemGroup>
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
<UseDebugLibraries>true</UseDebugLibraries>
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="PropertySheet.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
<PreprocessorDefinitions>_CONSOLE;WIN32_LEAN_AND_MEAN;WINRT_LEAN_AND_MEAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level4</WarningLevel>
<AdditionalOptions>%(AdditionalOptions) /permissive- /bigobj</AdditionalOptions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">onecore.lib;onecoreuap.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">onecore.lib;onecoreuap.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|x64'">onecore.lib;onecoreuap.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">onecore.lib;onecoreuap.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="console.h" />
<ClInclude Include="install.h" />
<ClInclude Include="packages.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="project_reunion_definitions.h" />
<ClInclude Include="resource.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="console.cpp" />
<ClCompile Include="install.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="PropertySheet.props" />
</ItemGroup>
<ItemDefinitionGroup Condition="Exists('project_reunion_definitions_override.h')">
<ClCompile>
<PreprocessorDefinitions>USE_DEFINITIONS_OVERRIDE_HEADER;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ResourceCompile Include="ProjectReunionInstall.rc">
<PreprocessorDefinitions Condition="Exists('project_reunion_definitions_override.h')">USE_DEFINITIONS_OVERRIDE_HEADER;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.201217.4\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.201217.4\build\native\Microsoft.Windows.CppWinRT.targets')" />
<Import Project="..\packages\Microsoft.Windows.ImplementationLibrary.1.0.201120.3\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.201120.3\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.201217.4\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.201217.4\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.201217.4\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.201217.4\build\native\Microsoft.Windows.CppWinRT.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.201120.3\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.ImplementationLibrary.1.0.201120.3\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
</Target>
</Project>

Просмотреть файл

@ -0,0 +1,60 @@
<?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;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;hm;inl;inc;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>
<ClInclude Include="pch.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="install.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="packages.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="project_reunion_definitions.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="console.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="install.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="console.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="PropertySheet.props" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="ProjectReunionInstall.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<!--
To customize common C++/WinRT project properties:
* right-click the project node
* expand the Common Properties item
* select the C++/WinRT property page
For more advanced scenarios, and complete documentation, please see:
https://github.com/Microsoft/cppwinrt/tree/master/nuget
-->
<PropertyGroup />
<ItemDefinitionGroup />
</Project>

11
installer/dev/console.cpp Normal file
Просмотреть файл

@ -0,0 +1,11 @@
#include "pch.h"
#include "console.h"
void ShowHelp()
{
std::wcout << L"Installs the Microsoft Project Reunion framework." << std::endl;
std::wcout << L" " << wil::GetModuleFileNameW(nullptr).get() << std::endl;
std::wcout << "Usage: " << std::endl;
std::wcout << " [--quiet] : Suppress all output." << std::endl;
std::wcout << " [-?] or [--help] : Show this text." << std::endl;
}

4
installer/dev/console.h Normal file
Просмотреть файл

@ -0,0 +1,4 @@
#pragma once
#include "pch.h"
void ShowHelp();

187
installer/dev/install.cpp Normal file
Просмотреть файл

@ -0,0 +1,187 @@
#include "pch.h"
#include "packages.h"
#include "install.h"
using namespace winrt;
using namespace Windows::ApplicationModel;
using namespace Windows::Foundation;
using namespace Windows::Management::Deployment;
using namespace Windows::System;
namespace ProjectReunionInstaller {
winrt::hresult AddPackage(const Uri& packageUri)
{
PackageManager packageManager;
const auto deploymentOperation{ packageManager.AddPackageAsync(packageUri, nullptr, DeploymentOptions::None) };
deploymentOperation.get();
if (deploymentOperation.Status() != AsyncStatus::Completed)
{
return deploymentOperation.ErrorCode();
}
return S_OK;
}
winrt::hresult ProvisionPackage(const std::wstring& packageFamilyName)
{
PackageManager packageManager;
const auto deploymentOperation{ packageManager.ProvisionPackageForAllUsersAsync(packageFamilyName.c_str()) };
deploymentOperation.get();
if (deploymentOperation.Status() != AsyncStatus::Completed)
{
return deploymentOperation.ErrorCode();
}
return S_OK;
}
bool IsArchitectureApplicable(const ProcessorArchitecture& arch)
{
SYSTEM_INFO systemInfo{};
GetNativeSystemInfo(&systemInfo);
const auto systemArchitecture{ static_cast<ProcessorArchitecture>(systemInfo.wProcessorArchitecture) };
// Neutral package architecture is applicable on all systems.
if (arch == ProcessorArchitecture::Neutral)
{
return true;
}
// Same-arch is always applicable.
if (arch == systemArchitecture)
{
return true;
}
// On x64 systems, x86 architecture is also applicable.
if (systemArchitecture == ProcessorArchitecture::X64 && arch == ProcessorArchitecture::X86)
{
return true;
}
// On Arm64 systems, all current package architectures are applicable.
if (systemArchitecture == ProcessorArchitecture::Arm64)
{
return true;
}
return false;
}
wil::com_ptr<IStream> CreateMemoryStream(const BYTE* data, size_t size)
{
wil::com_ptr<IStream> retval;
retval.attach(::SHCreateMemStream(data, size));
return retval;
}
wil::com_ptr<IStream> GetResourceStream(const std::wstring& resourceName, const std::wstring& resourceType)
{
HMODULE const hModule = GetModuleHandle(NULL);
HRSRC hResourceSource = ::FindResource(hModule, resourceName.c_str(), resourceType.c_str());
THROW_LAST_ERROR_IF_NULL(hResourceSource);
HGLOBAL hResource = LoadResource(hModule, hResourceSource);
THROW_LAST_ERROR_IF_NULL(hResource);
const BYTE* data = reinterpret_cast<BYTE*>(::LockResource(hResource));
THROW_LAST_ERROR_IF_NULL(data);
const DWORD size{ ::SizeofResource(hModule, hResourceSource) };
return CreateMemoryStream(data, size);
}
std::unique_ptr<PackageProperties> GetPackagePropertiesFromStream(wil::com_ptr<IStream>& stream)
{
// Get PackageId from the manifest.
auto factory = wil::CoCreateInstance<AppxFactory, IAppxFactory>();
wil::com_ptr<IAppxPackageReader> reader;
THROW_IF_FAILED(factory->CreatePackageReader(stream.get(), wil::out_param(reader)));
wil::com_ptr<IAppxManifestReader> manifest;
THROW_IF_FAILED(reader->GetManifest(wil::out_param(manifest)));
wil::com_ptr<IAppxManifestPackageId> id;
THROW_IF_FAILED(manifest->GetPackageId(&id));
// Populate properties from the manifest PackageId
auto properties = std::make_unique<PackageProperties>();
THROW_IF_FAILED(id->GetPackageFullName(&properties->fullName));
THROW_IF_FAILED(id->GetPackageFamilyName(&properties->familyName));
APPX_PACKAGE_ARCHITECTURE arch{};
THROW_IF_FAILED(id->GetArchitecture(&arch));
properties->architecture = static_cast<ProcessorArchitecture>(arch);
THROW_IF_FAILED(id->GetVersion(&properties->version));
return properties;
}
wil::com_ptr<IStream> OpenFileStream(PCWSTR path)
{
wil::com_ptr<IStream> outstream;
THROW_IF_FAILED(SHCreateStreamOnFileEx(path, STGM_WRITE | STGM_READ | STGM_SHARE_DENY_WRITE | STGM_CREATE, FILE_ATTRIBUTE_NORMAL, TRUE, nullptr, wil::out_param(outstream)));
return outstream;
}
void DeployPackageFromResource(const ProjectReunionInstaller::ResourcePackageInfo& resource, const bool quiet)
{
// Get package properties by loading the resource as a stream and reading the manifest.
auto packageStream = GetResourceStream(resource.id, resource.resourceType);
auto packageProperties = GetPackagePropertiesFromStream(packageStream);
// Skip non-applicable architectures.
if (!IsArchitectureApplicable(packageProperties->architecture))
{
return;
}
wchar_t packageFilename[MAX_PATH];
THROW_LAST_ERROR_IF(0 == GetTempFileName(std::filesystem::temp_directory_path().c_str(), L"PRP", 0u, packageFilename));
// GetTempFileName will create the temp file by that name due to the unique parameter being specified.
// From here on out if we leave scope for any reason we will attempt to delete that file.
auto removeTempFileOnScopeExit = wil::scope_exit([&]
{
LOG_IF_WIN32_BOOL_FALSE(::DeleteFile(packageFilename));
});
if (!quiet)
{
std::wcout << "Package Full Name: " << packageProperties->fullName.get() << std::endl;
std::wcout << "Temp package path: " << packageFilename << std::endl;
}
// Write the package to a temp file. The PackageManager APIs require a Uri.
wil::com_ptr<IStream> outStream{ OpenFileStream(packageFilename) };
ULARGE_INTEGER streamSize{};
THROW_IF_FAILED(::IStream_Size(packageStream.get(), &streamSize));
THROW_IF_FAILED(packageStream->CopyTo(outStream.get(), streamSize, nullptr, nullptr));
THROW_IF_FAILED(outStream->Commit(STGC_OVERWRITE));
outStream.reset();
// Add the package
Uri packageUri{ packageFilename };
hresult hrAddResult = AddPackage(packageUri);
if (!quiet)
{
std::wcout << "Package deployment result : 0x" << std::hex << hrAddResult.value << std::endl;
}
THROW_IF_FAILED(static_cast<HRESULT>(hrAddResult));
// Provisioning is expected to fail if the program is not run elevated or the user is not admin.
hresult hrProvisionResult = ProvisionPackage(packageProperties->familyName.get());
if (!quiet)
{
std::wcout << "Provisioning result : 0x" << std::hex << hrProvisionResult.value << std::endl;
}
LOG_IF_FAILED(static_cast<HRESULT>(hrProvisionResult));
return;
}
HRESULT DeployPackages(bool quiet) noexcept try
{
for (const auto& package : ProjectReunionInstaller::c_packages)
{
DeployPackageFromResource(package, quiet);
}
return S_OK;
}
CATCH_RETURN()
}

16
installer/dev/install.h Normal file
Просмотреть файл

@ -0,0 +1,16 @@
#pragma once
#include "pch.h"
#include "packages.h"
namespace ProjectReunionInstaller {
struct PackageProperties
{
wil::unique_cotaskmem_string fullName;
wil::unique_cotaskmem_string familyName;
winrt::Windows::System::ProcessorArchitecture architecture{ winrt::Windows::System::ProcessorArchitecture::Unknown };
std::uint64_t version{};
};
HRESULT DeployPackages(const bool quiet) noexcept;
}

36
installer/dev/main.cpp Normal file
Просмотреть файл

@ -0,0 +1,36 @@
#include "pch.h"
#include "console.h"
#include "install.h"
#include "resource.h"
using namespace winrt;
int wmain(int argc, wchar_t *argv[])
{
init_apartment();
bool quiet = false;
for (int i = 1; i < argc; ++i)
{
auto arg = std::wstring_view(argv[i]);
if ((arg == L"-q") || (arg == L"--quiet"))
{
quiet = true;
}
else if ((arg == L"-?") || (arg == L"--help"))
{
ShowHelp();
return 0;
}
else
{
std::wcerr << "Unknown argument: " << arg.data() << std::endl;
ShowHelp();
return ERROR_BAD_ARGUMENTS;
}
}
return ProjectReunionInstaller::DeployPackages(quiet);
}

Просмотреть файл

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.201217.4" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.201120.3" targetFramework="native" />
</packages>

32
installer/dev/packages.h Normal file
Просмотреть файл

@ -0,0 +1,32 @@
#pragma once
#include "pch.h"
#include "project_reunion_definitions.h"
using namespace winrt;
using namespace Windows::System;
// Information about the type of packages that are embedded
// More properties can be added as-needed, such as type - framework | main | appinstaller | bundle
// For now all packages are frameworks and only the processor architecture is meaningful.
namespace ProjectReunionInstaller {
struct ResourcePackageInfo
{
std::wstring id;
std::wstring resourceType;
};
static ResourcePackageInfo c_packages[] =
{
#if defined(PR_FRAMEWORK_X86_LISTENTRY)
PR_FRAMEWORK_X86_LISTENTRY
#endif
#if defined(PR_FRAMEWORK_X64_LISTENTRY)
PR_FRAMEWORK_X64_LISTENTRY
#endif
#if defined(PR_FRAMEWORK_ARM64_LISTENTRY)
PR_FRAMEWORK_ARM64_LISTENTRY
#endif
};
}

1
installer/dev/pch.cpp Normal file
Просмотреть файл

@ -0,0 +1 @@
#include "pch.h"

19
installer/dev/pch.h Normal file
Просмотреть файл

@ -0,0 +1,19 @@
#pragma once
#include <wil/result.h>
#include <wil/resource.h>
#include <wil/com.h>
#include <wil/win32_helpers.h>
#include <iostream>
#include <filesystem>
#include <processenv.h>
#include <shellapi.h>
#include <shlwapi.h>
#include <WinBase.h>
#include <AppxPackaging.h>
#include <string_view>
#include <winrt/Windows.ApplicationModel.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.Management.Deployment.h>
#include <winrt/Windows.Storage.h>
#include <winrt/Windows.System.h>

Просмотреть файл

@ -0,0 +1,64 @@
 #pragma once
// This header defines the packages included in the installer.
// By default, the project will use test packages built for verification of this installer.
// For building the installer with non-test packages, include a "project_reunion_definitions_override.h" file.
// If present, the override header will be loaded to change the package definitions such as the path.
// Preprocessor definitions used in the override header must be supported by the resource compiler.
// Override header file example:
//
// #pragma once
//
// #undef PR_FRAMEWORK_X86_PATH
// #define PR_FRAMEWORK_X86_PATH "custompackages\\my_custom_x86_framework.appx"
//
// Each package has a package definition listed below.
// Names for macros are intentionally kept short due to resource compiler length limitations.
// x86 Framework
#define PR_FRAMEWORK_X86_ID L"PR_FWPACKAGE_X86"
#define PR_FRAMEWORK_X86_RCID PR_FWPACKAGE_X86
#define PR_FRAMEWORK_X86_TYPE L"PACKAGE"
#define PR_FRAMEWORK_X86_RCTYPE PACKAGE
#define PR_FRAMEWORK_X86_PATH "..\\test\\testpackages\\framework_x86.msix"
// x64 Framework
#define PR_FRAMEWORK_X64_ID L"PR_FWPACKAGE_X64"
#define PR_FRAMEWORK_X64_RCID PR_FWPACKAGE_X64
#define PR_FRAMEWORK_X64_TYPE L"PACKAGE"
#define PR_FRAMEWORK_X64_RCTYPE PACKAGE
#define PR_FRAMEWORK_X64_PATH "..\\test\\testpackages\\framework_x64.msix"
// arm64 Framework
#define PR_FRAMEWORK_ARM64_ID L"PR_FWPACKAGE_ARM64"
#define PR_FRAMEWORK_ARM64_RCID PR_FWPACKAGE_ARM64
#define PR_FRAMEWORK_ARM64_TYPE L"PACKAGE"
#define PR_FRAMEWORK_ARM64_RCTYPE PACKAGE
#define PR_FRAMEWORK_ARM64_PATH "..\\test\\testpackages\\framework_arm64.msix"
// Package Inclusion
// Each package has a package list entry which defines its inclusion in packages.h and the .rc script.
// To not include a package, undefine the *_LISTENTRY and *_RCENTRY entries. At least one package must be included.
// x86 is included on all architecture flavors
#define PR_FRAMEWORK_X86_LISTENTRY { PR_FRAMEWORK_X86_ID, PR_FRAMEWORK_X86_TYPE },
#define PR_FRAMEWORK_X86_RCENTRY PR_FRAMEWORK_X86_RCID PR_FRAMEWORK_X86_RCTYPE PR_FRAMEWORK_X86_PATH
// x64 is included on all architecture flavors
#define PR_FRAMEWORK_X64_LISTENTRY { PR_FRAMEWORK_X64_ID, PR_FRAMEWORK_X64_TYPE },
#define PR_FRAMEWORK_X64_RCENTRY PR_FRAMEWORK_X64_RCID PR_FRAMEWORK_X64_RCTYPE PR_FRAMEWORK_X64_PATH
// arm64 is included only on arm64 builds
#if defined(_M_ARM64)
#define PR_FRAMEWORK_ARM64_LISTENTRY { PR_FRAMEWORK_ARM64_ID, PR_FRAMEWORK_ARM64_TYPE },
#define PR_FRAMEWORK_ARM64_RCENTRY PR_FRAMEWORK_ARM64_RC PR_FRAMEWORK_ARM64_RCTYPE PR_FRAMEWORK_ARM64_PATH
#endif
// This is defined in the vcxproj based on existence of the header in the same directory.
// It is defined in both the c compiler preprocessor definitions and the resource compiler preprocessor definitions.
#ifdef USE_DEFINITIONS_OVERRIDE_HEADER
#include "project_reunion_definitions_override.h"
#endif

15
installer/dev/resource.h Normal file
Просмотреть файл

@ -0,0 +1,15 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by ProjectReunionInstall.rc
//
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

Просмотреть файл

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30804.86
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateInstallerTestPackages", "CreateInstallerTestPackages.vcxproj", "{9C1A6C58-52D6-4514-9120-5C339C5DF4BE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9C1A6C58-52D6-4514-9120-5C339C5DF4BE}.Debug|x64.ActiveCfg = Debug|x64
{9C1A6C58-52D6-4514-9120-5C339C5DF4BE}.Debug|x64.Build.0 = Debug|x64
{9C1A6C58-52D6-4514-9120-5C339C5DF4BE}.Debug|x86.ActiveCfg = Debug|Win32
{9C1A6C58-52D6-4514-9120-5C339C5DF4BE}.Debug|x86.Build.0 = Debug|Win32
{9C1A6C58-52D6-4514-9120-5C339C5DF4BE}.Release|x64.ActiveCfg = Release|x64
{9C1A6C58-52D6-4514-9120-5C339C5DF4BE}.Release|x64.Build.0 = Release|x64
{9C1A6C58-52D6-4514-9120-5C339C5DF4BE}.Release|x86.ActiveCfg = Release|Win32
{9C1A6C58-52D6-4514-9120-5C339C5DF4BE}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5D0EEC5A-2B2E-473F-877D-4541C198D740}
EndGlobalSection
EndGlobal

Просмотреть файл

@ -0,0 +1,165 @@
<?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>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<ProjectGuid>{9C1A6C58-52D6-4514-9120-5C339C5DF4BE}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<ProjectName>CreateInstallerTestPackages</ProjectName>
<WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformMinVersion>10.0.17763.0</WindowsTargetPlatformMinVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</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>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<NMakeBuildCommandLine>nmake /f makefile.mak ProjectDir=$(ProjectDir) SolutionDir=$(SolutionDir) OutDir=$(OutDir) TargetName=$(TargetName) </NMakeBuildCommandLine>
<NMakeOutput>$(OutputPath)Microsoft.ProjectReunion.Test.InstallerPackages</NMakeOutput>
<NMakeCleanCommandLine>nmake /f makefile.mak ProjectDir=$(ProjectDir) SolutionDir=$(SolutionDir) OutDir=$(OutDir) TargetName=$(TargetName) clean</NMakeCleanCommandLine>
<NMakeReBuildCommandLine>nmake /f makefile.mak ProjectDir=$(ProjectDir) SolutionDir=$(SolutionDir) OutDir=$(OutDir) TargetName=$(TargetName) rebuild</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<OutDir>$(OutDir)</OutDir>
<IntDir>$(IntDir)</IntDir>
<NMakeIncludeSearchPath>$(SolutionDir)tools</NMakeIncludeSearchPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<NMakeBuildCommandLine>nmake /f makefile.mak ProjectDir=$(ProjectDir) SolutionDir=$(SolutionDir) OutDir=$(OutDir) TargetName=$(TargetName) </NMakeBuildCommandLine>
<NMakeOutput>$(OutputPath)Microsoft.ProjectReunion.Test.InstallerPackages</NMakeOutput>
<NMakeCleanCommandLine>nmake /f makefile.mak ProjectDir=$(ProjectDir) SolutionDir=$(SolutionDir) OutDir=$(OutDir) TargetName=$(TargetName) clean</NMakeCleanCommandLine>
<NMakeReBuildCommandLine>nmake /f makefile.mak ProjectDir=$(ProjectDir) SolutionDir=$(SolutionDir) OutDir=$(OutDir) TargetName=$(TargetName) rebuild</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<OutDir>$(OutDir)</OutDir>
<IntDir>$(IntDir)</IntDir>
<NMakeIncludeSearchPath>$(SolutionDir)tools</NMakeIncludeSearchPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<NMakeBuildCommandLine>nmake /f makefile.mak ProjectDir=$(ProjectDir) SolutionDir=$(SolutionDir) OutDir=$(OutDir) TargetName=$(TargetName) </NMakeBuildCommandLine>
<NMakeOutput>$(OutputPath)Microsoft.ProjectReunion.Test.InstallerPackages</NMakeOutput>
<NMakeCleanCommandLine>nmake /C /f makefile.mak ProjectDir=$(ProjectDir) SolutionDir=$(SolutionDir) OutDir=$(OutDir) TargetName=$(TargetName) clean</NMakeCleanCommandLine>
<NMakeReBuildCommandLine>nmake /C /f makefile.mak ProjectDir=$(ProjectDir) SolutionDir=$(SolutionDir) OutDir=$(OutDir) TargetName=$(TargetName) rebuild</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<OutDir>$(OutDir)</OutDir>
<IntDir>$(IntDir)</IntDir>
<NMakeIncludeSearchPath>$(SolutionDir)tools</NMakeIncludeSearchPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<NMakeBuildCommandLine>nmake /C /f makefile.mak ProjectDir=$(ProjectDir) SolutionDir=$(SolutionDir) OutDir=$(OutDir) TargetName=$(TargetName) </NMakeBuildCommandLine>
<NMakeOutput>$(OutputPath)Microsoft.ProjectReunion.Test.InstallerPackages</NMakeOutput>
<NMakeCleanCommandLine>nmake /C /f makefile.mak ProjectDir=$(ProjectDir) SolutionDir=$(SolutionDir) OutDir=$(OutDir) TargetName=$(TargetName) clean</NMakeCleanCommandLine>
<NMakeReBuildCommandLine>nmake /C /f makefile.mak ProjectDir=$(ProjectDir) SolutionDir=$(SolutionDir) OutDir=$(OutDir) TargetName=$(TargetName) rebuild</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<OutDir>$(OutDir)</OutDir>
<IntDir>$(IntDir)</IntDir>
<NMakeIncludeSearchPath>$(SolutionDir)tools</NMakeIncludeSearchPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<NMakeBuildCommandLine>nmake /f makefile.mak ProjectDir=$(ProjectDir) SolutionDir=$(SolutionDir) OutDir=$(OutDir) TargetName=$(TargetName) </NMakeBuildCommandLine>
<NMakeOutput>$(OutputPath)Microsoft.ProjectReunion.Test.InstallerPackages</NMakeOutput>
<NMakeCleanCommandLine>nmake /C /f makefile.mak ProjectDir=$(ProjectDir) SolutionDir=$(SolutionDir) OutDir=$(OutDir) TargetName=$(TargetName) clean</NMakeCleanCommandLine>
<NMakeReBuildCommandLine>nmake /C /f makefile.mak ProjectDir=$(ProjectDir) SolutionDir=$(SolutionDir) OutDir=$(OutDir) TargetName=$(TargetName) rebuild</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>WIN32;NDEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<OutDir>$(OutDir)</OutDir>
<IntDir>$(IntDir)</IntDir>
<NMakeIncludeSearchPath>$(SolutionDir)tools</NMakeIncludeSearchPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<NMakeBuildCommandLine>nmake /f makefile.mak ProjectDir=$(ProjectDir) SolutionDir=$(SolutionDir) OutDir=$(OutDir) TargetName=$(TargetName) </NMakeBuildCommandLine>
<NMakeOutput>$(OutputPath)Microsoft.ProjectReunion.Test.InstallerPackages</NMakeOutput>
<NMakeCleanCommandLine>nmake /f makefile.mak ProjectDir=$(ProjectDir) SolutionDir=$(SolutionDir) OutDir=$(OutDir) TargetName=$(TargetName) clean</NMakeCleanCommandLine>
<NMakeReBuildCommandLine>nmake /f makefile.mak ProjectDir=$(ProjectDir) SolutionDir=$(SolutionDir) OutDir=$(OutDir) TargetName=$(TargetName) rebuild</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>WIN32;NDEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<OutDir>$(OutDir)</OutDir>
<IntDir>$(IntDir)</IntDir>
<NMakeIncludeSearchPath>$(SolutionDir)tools</NMakeIncludeSearchPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<NMakeBuildCommandLine>nmake /f makefile.mak ProjectDir=$(ProjectDir) SolutionDir=$(SolutionDir) OutDir=$(OutDir) TargetName=$(TargetName) </NMakeBuildCommandLine>
<NMakeOutput>$(OutputPath)Microsoft.ProjectReunion.Test.InstallerPackages</NMakeOutput>
<NMakeCleanCommandLine>nmake /f makefile.mak ProjectDir=$(ProjectDir) SolutionDir=$(SolutionDir) OutDir=$(OutDir) TargetName=$(TargetName) clean</NMakeCleanCommandLine>
<NMakeReBuildCommandLine>nmake /f makefile.mak ProjectDir=$(ProjectDir) SolutionDir=$(SolutionDir) OutDir=$(OutDir) TargetName=$(TargetName) rebuild</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>WIN32;NDEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<OutDir>$(OutDir)</OutDir>
<IntDir>$(IntDir)</IntDir>
<NMakeIncludeSearchPath>$(SolutionDir)tools</NMakeIncludeSearchPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<NMakeBuildCommandLine>nmake /C /f makefile.mak ProjectDir=$(ProjectDir) SolutionDir=$(SolutionDir) OutDir=$(OutDir) TargetName=$(TargetName) </NMakeBuildCommandLine>
<NMakeOutput>$(OutputPath)Microsoft.ProjectReunion.Test.InstallerPackages</NMakeOutput>
<NMakeCleanCommandLine>nmake /C /f makefile.mak ProjectDir=$(ProjectDir) SolutionDir=$(SolutionDir) OutDir=$(OutDir) TargetName=$(TargetName) clean</NMakeCleanCommandLine>
<NMakeReBuildCommandLine>nmake /C /f makefile.mak ProjectDir=$(ProjectDir) SolutionDir=$(SolutionDir) OutDir=$(OutDir) TargetName=$(TargetName) rebuild</NMakeReBuildCommandLine>
<NMakePreprocessorDefinitions>NDEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<OutDir>$(OutDir)</OutDir>
<IntDir>$(IntDir)</IntDir>
<NMakeIncludeSearchPath>$(SolutionDir)tools</NMakeIncludeSearchPath>
</PropertyGroup>
<ItemDefinitionGroup>
</ItemDefinitionGroup>
<ItemGroup>
<Xml Include="appxmanifest_arm64.xml" />
<Xml Include="appxmanifest_x64.xml" />
<Xml Include="appxmanifest_x86.xml" />
</ItemGroup>
<ItemGroup>
<None Include="Makefile.mak" />
<None Include="README.md" />
</ItemGroup>
<ItemGroup>
<Image Include="logo.png" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

Просмотреть файл

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Xml Include="appxmanifest_arm64.xml" />
<Xml Include="appxmanifest_x64.xml" />
<Xml Include="appxmanifest_x86.xml" />
</ItemGroup>
<ItemGroup>
<None Include="Makefile.mak" />
<None Include="README.md" />
</ItemGroup>
<ItemGroup>
<Image Include="logo.png" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,72 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See LICENSE in the project root for license information.
MAKEAPPX_OPTS=
!IFDEF VERBOSE
MAKEAPPX_OPTS=/v
!ENDIF
SIGNTOOL_OPTS=
!IFDEF VERBOSE
SIGNTOOL_OPTS=/v
!ENDIF
!IFDEF VERBOSE
!MESSAGE SolutionDir =$(SolutionDir)
!MESSAGE ProjectDir =$(ProjectDir)
!MESSAGE OutDir =$(OutDir)
!MESSAGE TargetName =$(TargetName)
!ENDIF
TARGET_BASENAME=Microsoft.ProjectReunion.Test.InstallerFramework
TargetDir=$(OutDir)$(TargetName)
MSTestCert=$(SolutionDir)..\..\build\MSTest.pfx
InstallerPackagesDir=$(SolutionDir)\..\testpackages
WorkDir_x86=$(TargetDir)\msix_x86
WorkDir_x64=$(TargetDir)\msix_x64
WorkDir_arm64=$(TargetDir)\msix_arm64
OutMsix_x86=$(TargetDir)\$(TargetName)_x86.msix
OutMsix_x64=$(TargetDir)\$(TargetName)_x64.msix
OutMsix_arm64=$(TargetDir)\$(TargetName)_arm64.msix
Framework_x86=$(InstallerPackagesDir)\framework_x86.msix
Framework_x64=$(InstallerPackagesDir)\framework_x64.msix
Framework_arm64=$(InstallerPackagesDir)\framework_arm64.msix
all: build
$(OutMsix_x86): $(ProjectDir)appxmanifest_x86.xml
@if not exist $(WorkDir_x86) md $(WorkDir_x86) >NUL
@copy /Y $(ProjectDir)appxmanifest_x86.xml $(WorkDir_x86)\appxmanifest.xml >NUL
@copy /Y $(ProjectDir)logo.png $(WorkDir_x86)\logo.png >NUL
@makeappx.exe pack $(MAKEAPPX_OPTS)/o /h SHA256 /d $(WorkDir_x86) /p $(OutMsix_x86)
@signtool.exe sign /a $(SIGNTOOL_OPTS) /fd SHA256 /f $(MSTestCert) $(OutMsix_x86)
@if not exist $(InstallerPackagesDir) md $(InstallerPackagesDir)
@copy /Y $(OutMsix_x86) $(Framework_x86) >NUL
$(OutMsix_x64): $(ProjectDir)appxmanifest_x64.xml
@if not exist $(WorkDir_x64) md $(WorkDir_x64) >NUL
@copy /Y $(ProjectDir)appxmanifest_x64.xml $(WorkDir_x64)\appxmanifest.xml >NUL
@copy /Y $(ProjectDir)logo.png $(WorkDir_x64)\logo.png >NUL
@makeappx.exe pack $(MAKEAPPX_OPTS)/o /h SHA256 /d $(WorkDir_x64) /p $(OutMsix_x64)
@signtool.exe sign /a $(SIGNTOOL_OPTS) /fd SHA256 /f $(MSTestCert) $(OutMsix_x64)
@if not exist $(InstallerPackagesDir) md $(InstallerPackagesDir)
@copy /Y $(OutMsix_x64) $(Framework_x64) >NUL
$(OutMsix_arm64): $(ProjectDir)appxmanifest_arm64.xml
@if not exist $(WorkDir_arm64) md $(WorkDir_arm64) >NUL
@copy /Y $(ProjectDir)appxmanifest_arm64.xml $(WorkDir_arm64)\appxmanifest.xml >NUL
@copy /Y $(ProjectDir)logo.png $(WorkDir_arm64)\logo.png >NUL
@makeappx.exe pack $(MAKEAPPX_OPTS)/o /h SHA256 /d $(WorkDir_arm64) /p $(OutMsix_arm64)
@signtool.exe sign /a $(SIGNTOOL_OPTS) /fd SHA256 /f $(MSTestCert) $(OutMsix_arm64)
@if not exist $(InstallerPackagesDir) md $(InstallerPackagesDir)
@copy /Y $(OutMsix_arm64) $(Framework_arm64) >NUL
build: $(OutMsix_x86) $(OutMsix_x64) $(OutMsix_arm64)
clean:
@if exist $(TargetDir) rd $(TargetDir) /s /q
@if exist $(InstallerPackagesDir) rd $(InstallerPackagesDir) /s /q
rebuild: clean build

Просмотреть файл

@ -0,0 +1,14 @@
### Create Installer Test Packages
This project builds test packages for the installer. Since the installer must be built with packages, these are the default packages it targets for inclusion.
These can be used for testing the installer itself without interfering with real Project Reunion packages that may be on the system. Real packages built with the
installer are to be done using the override header, specified in project_reunion_definitions.h
These packages are dummy packages that do not contain any running code and are only intended to test deployment operations done by the installer. They are built
for all architectures and placed in the same "installerpackages" folder. The reason they are copied to this location is due to limitations with the resource
compiler, which does not support the same preprocessor macros and definitions as the C++ compiler. To avoid unnecessary complexity with the resource compiler,
the input packages for the installer are always copied to the same location where they can easily be specified in a preprocessor macro.
To save build time and signing complexities, this project only needs to be built when new test packages need to be added or generated and added as test collateral.

Просмотреть файл

@ -0,0 +1,28 @@
<?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"
IgnorableNamespaces="uap">
<Identity
Name="Microsoft.ProjectReunion.Test.InstallerFramework"
Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
Version="1.0.0.0" />
<Properties>
<DisplayName>Microsoft.ProjectReunion.Test.InstallerFramework for tests</DisplayName>
<PublisherDisplayName>Project Reunion</PublisherDisplayName>
<Logo>logo.png</Logo>
<Framework>true</Framework>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
</Dependencies>
<Resources>
<Resource Language="en"/>
</Resources>
</Package>

Просмотреть файл

@ -0,0 +1,29 @@
<?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"
IgnorableNamespaces="uap">
<Identity
Name="Microsoft.ProjectReunion.Test.InstallerFramework"
Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
ProcessorArchitecture="arm64"
Version="1.0.0.0" />
<Properties>
<DisplayName>Microsoft.ProjectReunion.Test.InstallerFramework for tests</DisplayName>
<PublisherDisplayName>Project Reunion</PublisherDisplayName>
<Logo>logo.png</Logo>
<Framework>true</Framework>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
</Dependencies>
<Resources>
<Resource Language="en"/>
</Resources>
</Package>

Просмотреть файл

@ -0,0 +1,29 @@
<?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"
IgnorableNamespaces="uap">
<Identity
Name="Microsoft.ProjectReunion.Test.InstallerFramework"
Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
ProcessorArchitecture="x64"
Version="1.0.0.0" />
<Properties>
<DisplayName>Microsoft.ProjectReunion.Test.InstallerFramework for tests</DisplayName>
<PublisherDisplayName>Project Reunion</PublisherDisplayName>
<Logo>logo.png</Logo>
<Framework>true</Framework>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
</Dependencies>
<Resources>
<Resource Language="en"/>
</Resources>
</Package>

Просмотреть файл

@ -0,0 +1,29 @@
<?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"
IgnorableNamespaces="uap">
<Identity
Name="Microsoft.ProjectReunion.Test.InstallerFramework"
Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
ProcessorArchitecture="x86"
Version="1.0.0.0" />
<Properties>
<DisplayName>Microsoft.ProjectReunion.Test.InstallerFramework for tests</DisplayName>
<PublisherDisplayName>Microsoft Corporation</PublisherDisplayName>
<Logo>logo.png</Logo>
<Framework>true</Framework>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
</Dependencies>
<Resources>
<Resource Language="en"/>
</Resources>
</Package>

Двоичные данные
installer/test/CreateInstallerTestPackages/logo.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 4.3 KiB

Просмотреть файл

@ -0,0 +1,74 @@
#include "pch.h"
#include "helpers.h"
#include "constants.h"
#include "CppUnitTest.h"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
using namespace winrt::Windows::System;
namespace ProjectReunionInstallerTests
{
TEST_CLASS(FunctionalTests)
{
public:
TEST_METHOD_INITIALIZE(Initialize)
{
RemoveAllPackages();
}
TEST_METHOD_CLEANUP(Cleanup)
{
RemoveAllPackages();
}
TEST_METHOD(VerifyInstallerRuns)
{
auto result = RunInstaller();
Assert::AreEqual(result, S_OK);
}
TEST_METHOD(VerifyArgsQuiet)
{
auto result = RunInstaller(L"--quiet");
Assert::AreEqual(result, S_OK);
}
TEST_METHOD(VerifyArgsHelp)
{
auto result = RunInstaller(L"--help");
Assert::AreEqual(result, S_OK);
}
TEST_METHOD(VerifyArgsInvalid)
{
// Installer should fail with bad arguments error code.
auto result = RunInstaller(L"--kittens");
Assert::AreEqual(result, HRESULT_FROM_WIN32(ERROR_BAD_ARGUMENTS));
}
TEST_METHOD(RunInstallerAndVerifyPackages)
{
// Run and verify installer
auto result = RunInstaller();
Assert::AreEqual(result, S_OK);
// Verify frameworks based on system architecture
auto systemArch = GetSystemArchitecture();
// x86 should be registered on every platform.
Assert::AreEqual(true, IsPackageRegistered(c_x86FrameworkName));
// x64 should be registered on x64 and arm64.
if (systemArch == ProcessorArchitecture::X64 || systemArch == ProcessorArchitecture::Arm64)
{
Assert::AreEqual(true, IsPackageRegistered(c_x64FrameworkName));
}
// arm64 should be registered on arm64.
if (systemArch == ProcessorArchitecture::Arm64)
{
Assert::AreEqual(true, IsPackageRegistered(c_arm64FrameworkName));
}
}
};
}

Просмотреть файл

@ -0,0 +1,42 @@
<?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>
<ClCompile Include="FunctionalTests.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="pch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="helpers.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="helpers.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="constants.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,190 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\packages\Microsoft.Windows.CppWinRT.2.0.210211.2\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.210211.2\build\native\Microsoft.Windows.CppWinRT.props')" />
<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>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<ProjectGuid>{79830E23-FAA6-4C02-A83A-419B68434AA7}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>InstallerFunctionalTests</RootNamespace>
<ProjectSubType>NativeUnitTestProject</ProjectSubType>
<ProjectName>InstallerFunctionalTests</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</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>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UseFullPaths>true</UseFullPaths>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="FunctionalTests.cpp" />
<ClCompile Include="helpers.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="constants.h" />
<ClInclude Include="helpers.h" />
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.210204.1\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.210204.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
<Import Project="..\..\packages\Microsoft.Windows.CppWinRT.2.0.210211.2\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.210211.2\build\native\Microsoft.Windows.CppWinRT.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.210204.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.210204.1\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.210211.2\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Windows.CppWinRT.2.0.210211.2\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.210211.2\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Windows.CppWinRT.2.0.210211.2\build\native\Microsoft.Windows.CppWinRT.targets'))" />
</Target>
</Project>

Просмотреть файл

@ -0,0 +1,37 @@
#pragma once
#if defined(_M_IX86)
#define ARCH L"x86"
#elif defined(_M_AMD64)
#define ARCH L"x64"
#elif defined(_M_ARM64)
#define ARCH L"arm64"
#else
#error "Unknown architcture"
#endif
#if defined(_DEBUG)
#define CONFIGURATION L"Debug"
#else
#define CONFIGURATION L"Release"
#endif
#define BASE_PATH L"..\\..\\..\\"
#define INSTALLER_DIR L"ProjectReunionInstall"
#define INSTALLER_FILENAME L"ProjectReunionInstall.exe"
#define INSTALLER_EXE_PATH BASE_PATH CONFIGURATION L"\\" ARCH L"\\" INSTALLER_DIR L"\\" INSTALLER_FILENAME
namespace ProjectReunionInstallerTests
{
static const int c_phaseTimeout = (30 * 1000); // 30 seconds
static const std::wstring c_x86FrameworkName = L"Microsoft.ProjectReunion.Test.InstallerFramework_1.0.0.0_x86__8wekyb3d8bbwe";
static const std::wstring c_x64FrameworkName = L"Microsoft.ProjectReunion.Test.InstallerFramework_1.0.0.0_x64__8wekyb3d8bbwe";
static const std::wstring c_arm64FrameworkName = L"Microsoft.ProjectReunion.Test.InstallerFramework_1.0.0.0_arm64__8wekyb3d8bbwe";
static const std::wstring c_packages[] = {
c_x86FrameworkName,
c_x64FrameworkName,
c_arm64FrameworkName,
};
}

Просмотреть файл

@ -0,0 +1,98 @@
#include "pch.h"
#include "constants.h"
#include "helpers.h"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
using namespace winrt::Windows::Foundation;
using namespace winrt::Windows::Foundation::Collections;
using namespace winrt::Windows::Management::Deployment;
using namespace winrt::Windows::System;
namespace ProjectReunionInstallerTests
{
wil::unique_handle Execute(const std::wstring& command, const std::wstring& args)
{
SHELLEXECUTEINFO ei{};
ei.cbSize = sizeof(SHELLEXECUTEINFO);
ei.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_DOENVSUBST;
ei.lpFile = command.c_str();
ei.lpParameters = args.c_str();
if (!ShellExecuteEx(&ei))
{
auto lastError = GetLastError();
Assert::AreEqual(S_OK, HRESULT_FROM_WIN32(lastError));
}
wil::unique_handle process{ ei.hProcess };
return process;
}
HRESULT RunInstaller(const std::wstring& args)
{
std::wostringstream sstr;
sstr << L"Running installer at: " << INSTALLER_EXE_PATH << std::endl;
sstr << L"Arguments: " << args << std::endl;
Logger::WriteMessage(sstr.str().c_str());
auto process = Execute(INSTALLER_EXE_PATH, args);
auto waitResult = WaitForSingleObject(process.get(), c_phaseTimeout);
if (waitResult != WAIT_OBJECT_0)
{
auto lastError = GetLastError();
Assert::AreNotEqual(S_OK, HRESULT_FROM_WIN32(lastError));
}
DWORD exitCode{};
THROW_IF_WIN32_BOOL_FALSE(GetExitCodeProcess(process.get(), &exitCode));
return HRESULT_FROM_WIN32(exitCode);
}
void RemovePackage(const std::wstring& packageName, bool ignoreFailures)
{
std::wostringstream sstr;
sstr << L"Removing package: " << packageName << std::endl;
Logger::WriteMessage(sstr.str().c_str());
PackageManager manager;
auto result = manager.RemovePackageAsync(packageName).get();
auto errorCode = result.ExtendedErrorCode();
if (!ignoreFailures)
{
winrt::check_hresult(errorCode);
}
}
void RemoveAllPackages(bool ignoreFailures)
{
for (const auto& packageName : c_packages)
{
RemovePackage(packageName, ignoreFailures);
}
}
bool IsPackageRegistered(const std::wstring& packageFullName)
{
PackageManager manager;
auto result = manager.FindPackageForUser(L"", packageFullName);
std::wostringstream sstr;
sstr << L"Package " << packageFullName << " is ";
if (!result)
{
sstr << L"not ";
}
sstr << L"registered." << std::endl;
Logger::WriteMessage(sstr.str().c_str());
return result != nullptr;
}
ProcessorArchitecture GetSystemArchitecture()
{
SYSTEM_INFO systemInfo{};
GetNativeSystemInfo(&systemInfo);
return static_cast<ProcessorArchitecture>(systemInfo.wProcessorArchitecture);
}
}

Просмотреть файл

@ -0,0 +1,13 @@
#pragma once
#include "pch.h"
#include "CppUnitTest.h"
namespace ProjectReunionInstallerTests
{
wil::unique_handle Execute(const std::wstring& command, const std::wstring& args);
HRESULT RunInstaller(const std::wstring& args=L"");
void RemovePackage(const std::wstring& packageFullName, bool ignoreFailures=true);
void RemoveAllPackages(bool ignoreFailures=true);
bool IsPackageRegistered(const std::wstring& packageFullName);
winrt::Windows::System::ProcessorArchitecture GetSystemArchitecture();
}

Просмотреть файл

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.210211.2" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.210204.1" targetFramework="native" />
</packages>

Просмотреть файл

@ -0,0 +1,5 @@
// pch.cpp: source file corresponding to the pre-compiled header
#include "pch.h"
// When you are using pre-compiled headers, this source file is necessary for compilation to succeed.

Просмотреть файл

@ -0,0 +1,23 @@
// pch.h: This is a precompiled header file.
// Files listed below are compiled only once, improving build performance for future builds.
// This also affects IntelliSense performance, including code completion and many code browsing features.
// However, files listed here are ALL re-compiled if any one of them is updated between builds.
// Do not add files here that you will be updating frequently as this negates the performance advantage.
#ifndef PCH_H
#define PCH_H
#include <windows.h>
#include <wil/result.h>
#include <wil/cppwinrt.h>
#include <wil/resource.h>
#include <string>
#include <sstream>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.Management.Deployment.h>
#include <winrt/Windows.System.h>
#endif //PCH_H

Двоичные данные
installer/test/testpackages/framework_arm64.msix Normal file

Двоичный файл не отображается.

Двоичные данные
installer/test/testpackages/framework_x64.msix Normal file

Двоичный файл не отображается.

Двоичные данные
installer/test/testpackages/framework_x86.msix Normal file

Двоичный файл не отображается.