Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…o user/kythant/vsconfig1
  • Loading branch information
kythant committed Aug 19, 2022
2 parents b281a56 + 7203b49 commit 31519ca
Show file tree
Hide file tree
Showing 65 changed files with 1,796 additions and 65 deletions.
194 changes: 189 additions & 5 deletions WindowsAppRuntime.sln

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ jobs:
Copy-Item -Path "$targetsFilePath\Microsoft.WindowsAppSDK.Bootstrap.CS.targets" -Destination "$fullpackagePath\build\Microsoft.WindowsAppSDK.Bootstrap.CS.targets"
Copy-Item -Path "$targetsFilePath\WindowsAppSDK-Nuget-Native.Bootstrap.targets" -Destination "$fullpackagePath\build\native\WindowsAppSDK-Nuget-Native.Bootstrap.targets"
Copy-Item -Path "$targetsFilePath\Microsoft.WindowsAppSDK.BootstrapCommon.targets" -Destination "$fullpackagePath\build\Microsoft.WindowsAppSDK.BootstrapCommon.targets"
Copy-Item -Path "$targetsFilePath\Microsoft.WindowsAppSDK.DeploymentManager.CS.targets" -Destination "$fullpackagePath\build\Microsoft.WindowsAppSDK.DeploymentManager.CS.targets"
Copy-Item -Path "$targetsFilePath\WindowsAppSDK-Nuget-Native.DeploymentManager.targets" -Destination "$fullpackagePath\build\native\WindowsAppSDK-Nuget-Native.DeploymentManager.targets"
Copy-Item -Path "$targetsFilePath\Microsoft.WindowsAppSDK.DeploymentManagerCommon.targets" -Destination "$fullpackagePath\build\Microsoft.WindowsAppSDK.DeploymentManagerCommon.targets"
Copy-Item -Path "$targetsFilePath\Microsoft.WindowsAppSDK.UndockedRegFreeWinRT.CS.targets" -Destination "$fullpackagePath\build\Microsoft.WindowsAppSDK.UndockedRegFreeWinRT.CS.targets"
Copy-Item -Path "$targetsFilePath\WindowsAppSDK-Nuget-Native.UndockedRegFreeWinRT.targets" -Destination "$fullpackagePath\build\native\WindowsAppSDK-Nuget-Native.UndockedRegFreeWinRT.targets"
Copy-Item -Path "$targetsFilePath\Microsoft.WindowsAppSDK.UndockedRegFreeWinRTCommon.targets" -Destination "$fullpackagePath\build\Microsoft.WindowsAppSDK.UndockedRegFreeWinRTCommon.targets"
Expand Down
4 changes: 4 additions & 0 deletions build/CopyFilesToStagingDir.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windo
PublishFile $FullBuildOutput\WindowsAppRuntime_BootstrapDLL\MddBootstrapAutoInitializer.cpp $NugetDir\include
PublishFile $FullBuildOutput\WindowsAppRuntime_BootstrapDLL\MddBootstrapAutoInitializer.cs $NugetDir\include
#
# DeploymentManager Auto-Initializer Files
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\DeploymentManagerAutoInitializer.cpp $NugetDir\include
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\DeploymentManagerAutoInitializer.cs $NugetDir\include
#
# UndockedRegFreeWinRT (URFW) Auto-Initializer Files
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\UndockedRegFreeWinRT-AutoInitializer.cpp $NugetDir\include
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\UndockedRegFreeWinRT-AutoInitializer.cs $NugetDir\include
Expand Down
20 changes: 20 additions & 0 deletions build/NuSpecs/Microsoft.WindowsAppSDK.DeploymentManager.CS.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<DefineConstants Condition="'$(WindowsAppSDKDeploymentManagerAutoInitializeOptions_Default)'=='true'">$(DefineConstants);MICROSOFT_WINDOWSAPPSDK_DEPLOYMENTMANAGER_AUTO_INITIALIZE_OPTIONS_DEFAULT</DefineConstants>
<DefineConstants Condition="'$(WindowsAppSDKDeploymentManagerAutoInitializeOptions_None)'=='true'">$(DefineConstants);MICROSOFT_WINDOWSAPPSDK_DEPLOYMENTMANAGER_AUTO_INITIALIZE_OPTIONS_NONE</DefineConstants>
<DefineConstants Condition="'$(WindowsAppSDKDeploymentManagerAutoInitializeOptions_OnError_DebugBreak)'=='true'">$(DefineConstants);MICROSOFT_WINDOWSAPPSDK_DEPLOYMENTMANAGER_AUTO_INITIALIZE_OPTIONS_ONERROR_DEBUGBREAK</DefineConstants>
<DefineConstants Condition="'$(WindowsAppSDKDeploymentManagerAutoInitializeOptions_OnError_DebugBreak_IfDebuggerAttached)'=='true'">$(DefineConstants);MICROSOFT_WINDOWSAPPSDK_DEPLOYMENTMANAGER_AUTO_INITIALIZE_OPTIONS_ONERROR_DEBUGBREAK_IFDEBUGGERATTACHED</DefineConstants>
<DefineConstants Condition="'$(WindowsAppSDKDeploymentManagerAutoInitializeOptions_OnError_FailFast)'=='true'">$(DefineConstants);MICROSOFT_WINDOWSAPPSDK_DEPLOYMENTMANAGER_AUTO_INITIALIZE_OPTIONS_ONERROR_FAILFAST</DefineConstants>
<DefineConstants Condition="'$(WindowsAppSDKDeploymentManagerAutoInitializeOptions_OnNoMatch_ShowUI)'=='true'">$(DefineConstants);MICROSOFT_WINDOWSAPPSDK_DEPLOYMENTMANAGER_AUTO_INITIALIZE_OPTIONS_ONNOMATCH_SHOWUI</DefineConstants>
<DefineConstants Condition="'$(WindowsAppSDKDeploymentManagerAutoInitializeOptions_OnPackageIdentity_NoOp)'=='true'">$(DefineConstants);MICROSOFT_WINDOWSAPPSDK_DEPLOYMENTMANAGER_AUTO_INITIALIZE_OPTIONS_ONPACKAGEIDENTITY_NOOP</DefineConstants>
</PropertyGroup>

<Target Name="GenerateDeploymentManagerCS" BeforeTargets="BeforeCompile">
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)..\include\DeploymentManagerAutoInitializer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)..\include\WindowsAppSDK-VersionInfo.cs" />
</ItemGroup>
</Target>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!-- Targets file common to both managed and native projects -->

<PropertyGroup Condition="'$(WindowsAppSdkDeploymentManagerInitialize)'=='' and '$(WindowsAppSDKSelfContained)'!='true' and '$(WindowsPackageType)'=='None' and ('$(OutputType)'=='Exe' or '$(OutputType)'=='Winexe')">
<!--Allows GenerateDeploymentManagerCS/GenerateDeploymentManagerCpp to run-->
<!--
TODO Uncomment when ready to enable default
Franken-builds giving weird results after way too much manual hackery
so can't get a reliable read on if it's good or what's wrong. Enable
it all but inert unless explicitly requested (which no one does today)
to have viable packages for testing.
<WindowsAppSdkDeploymentManagerInitialize>true</WindowsAppSdkDeploymentManagerInitialize>
-->
</PropertyGroup>

<PropertyGroup Condition="'$(WindowsAppSdkDeploymentManagerInitialize)'== 'true'">
<PublishAppxPackage>false</PublishAppxPackage>
</PropertyGroup>

</Project>
3 changes: 3 additions & 0 deletions build/NuSpecs/Microsoft.WindowsAppSDK.Foundation.targets
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@
<Import Project="$(MSBuildThisFileDirectory)Microsoft.WindowsAppSDK.UndockedRegFreeWinRTCommon.targets" />
<Import Project="$(MSBuildThisFileDirectory)Microsoft.WindowsAppSDK.UndockedRegFreeWinRT.CS.targets" Condition="'$(WindowsAppSdkUndockedRegFreeWinRTInitialize)' == 'true'"/>

<Import Project="$(MSBuildThisFileDirectory)Microsoft.WindowsAppSDK.DeploymentManagerCommon.targets" />
<Import Project="$(MSBuildThisFileDirectory)Microsoft.WindowsAppSDK.DeploymentManager.CS.targets" Condition="'$(WindowsAppSdkDeploymentManagerInitialize)' == 'true'"/>

</Project>
18 changes: 18 additions & 0 deletions build/NuSpecs/WindowsAppSDK-Nuget-Native.DeploymentManager.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<Target Name="GenerateDeploymentManagerCpp" BeforeTargets="ClCompile">
<ItemGroup>
<ClCompile Include="$(MSBuildThisFileDirectory)..\..\include\DeploymentManagerAutoInitializer.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PreprocessorDefinitions Condition="'$(WindowsAppSDKDeploymentManagerAutoInitializeOptions_Default)'=='true'">MICROSOFT_WINDOWSAPPSDK_DEPLOYMENTMANAGER_AUTO_INITIALIZE_OPTIONS_DEFAULT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(WindowsAppSDKDeploymentManagerAutoInitializeOptions_None)'=='true'">MICROSOFT_WINDOWSAPPSDK_DEPLOYMENTMANAGER_AUTO_INITIALIZE_OPTIONS_NONE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(WindowsAppSDKDeploymentManagerAutoInitializeOptions_OnError_DebugBreak)'=='true'">MICROSOFT_WINDOWSAPPSDK_DEPLOYMENTMANAGER_AUTO_INITIALIZE_OPTIONS_ONERROR_DEBUGBREAK;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(WindowsAppSDKDeploymentManagerAutoInitializeOptions_OnError_DebugBreak_IfDebuggerAttached)'=='true'">MICROSOFT_WINDOWSAPPSDK_DEPLOYMENTMANAGER_AUTO_INITIALIZE_OPTIONS_ONERROR_DEBUGBREAK_IFDEBUGGERATTACHED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(WindowsAppSDKDeploymentManagerAutoInitializeOptions_OnError_FailFast)'=='true'">MICROSOFT_WINDOWSAPPSDK_DEPLOYMENTMANAGER_AUTO_INITIALIZE_OPTIONS_ONERROR_FAILFAST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(WindowsAppSDKDeploymentManagerAutoInitializeOptions_OnNoMatch_ShowUI)'=='true'">MICROSOFT_WINDOWSAPPSDK_DEPLOYMENTMANAGER_AUTO_INITIALIZE_OPTIONS_ONNOMATCH_SHOWUI;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(WindowsAppSDKDeploymentManagerAutoInitializeOptions_OnPackageIdentity_NoOp)'=='true'">MICROSOFT_WINDOWSAPPSDK_DEPLOYMENTMANAGER_AUTO_INITIALIZE_OPTIONS_ONPACKAGEIDENTITY_NOOP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemGroup>
</Target>

</Project>
3 changes: 3 additions & 0 deletions build/NuSpecs/WindowsAppSDK-Nuget-Native.targets
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,7 @@
<Import Project="$(MSBuildThisFileDirectory)..\Microsoft.WindowsAppSDK.UndockedRegFreeWinRTCommon.targets" />
<Import Project="$(MSBuildThisFileDirectory)WindowsAppSDK-Nuget-Native.UndockedRegFreeWinRT.targets" Condition="'$(WindowsAppSdkUndockedRegFreeWinRTInitialize)' == 'true'"/>

<Import Project="$(MSBuildThisFileDirectory)..\Microsoft.WindowsAppSDK.DeploymentManagerCommon.targets" />
<Import Project="$(MSBuildThisFileDirectory)WindowsAppSDK-Nuget-Native.DeploymentManager.targets" Condition="'$(WindowsAppSdkDeploymentManagerInitialize)' == 'true'"/>

</Project>
86 changes: 86 additions & 0 deletions dev/Common/AppModel.Identity.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,92 @@ inline std::wstring GetVersionShortTagFromVersionTag(
}
return versionShortTag;
}

/// Package Identity
class PackageIdentity
{
public:
static PackageIdentity FromPackageFullName(PCWSTR packageFullName)
{
PackageIdentity packageIdentity;
UINT32 bufferLength{ sizeof(packageIdentity.m_buffer) };
THROW_IF_WIN32_ERROR(PackageIdFromFullName(packageFullName, PACKAGE_INFORMATION_BASIC, &bufferLength, packageIdentity.m_buffer));
packageIdentity.m_packageId = reinterpret_cast<PACKAGE_ID*>(packageIdentity.m_buffer);
packageIdentity.m_packageFullName = packageFullName;
return packageIdentity;
}

public:
PackageIdentity() = default;

PackageIdentity(PackageIdentity&& other) :
m_packageFullName(std::move(other.m_packageFullName))
{
memcpy(m_buffer, other.m_buffer, sizeof(m_buffer));
m_packageId = reinterpret_cast<PACKAGE_ID*>(m_buffer);

other.m_packageId = nullptr;
memset(other.m_buffer, 0, sizeof(other.m_buffer));
}

~PackageIdentity() = default;

PackageIdentity& operator=(PackageIdentity&& other)
{
if (this != &other)
{
m_packageFullName = std::move(other.m_packageFullName);
memcpy(m_buffer, other.m_buffer, sizeof(m_buffer));
m_packageId = reinterpret_cast<PACKAGE_ID*>(m_buffer);

other.m_packageId = nullptr;
memset(other.m_buffer, 0, sizeof(other.m_buffer));
}
return *this;
}

const std::wstring& PackageFullName() const
{
return m_packageFullName;
}

PCWSTR Name() const
{
return m_packageId->name;
}

PACKAGE_VERSION Version() const
{
return m_packageId->version;
}

winrt::Windows::System::ProcessorArchitecture Architecture() const
{
return static_cast<winrt::Windows::System::ProcessorArchitecture>(m_packageId->processorArchitecture);
}

PCWSTR ResourceId() const
{
return m_packageId->resourceId;
}

PCWSTR PublisherId() const
{
return m_packageId->publisherId;
}

explicit operator bool() const
{
return m_packageId != nullptr;
}

private:
std::wstring m_packageFullName;
const PACKAGE_ID * m_packageId{};
BYTE m_buffer[sizeof(PACKAGE_ID) + (PACKAGE_NAME_MAX_LENGTH + 1 +
PACKAGE_RESOURCEID_MAX_LENGTH + 1 +
PACKAGE_PUBLISHERID_MAX_LENGTH + 1) * sizeof(WCHAR)]{};
};
}

#endif // __APPMODEL_IDENTITY_H
5 changes: 5 additions & 0 deletions dev/Common/IsWindowsVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ inline bool IsWindows10_20H1OrGreater()
// GetPackageInfo3() added to kernelbase.dll in NTDDI_WIN10_VB (aka 20H1)
return IsExportPresent(L"kernelbase.dll", "GetPackageInfo3");
}
inline bool IsWindows11_21H2OrGreater()
{
// GetMachineTypeAttributes() added to kernelbase.dll in NTDDI_WIN10_CO (aka Windows 11 21H2)
return IsExportPresent(L"kernelbase.dll", "GetMachineTypeAttributes");
}
}

#endif // __ISWINDOWSVERSION_H
27 changes: 27 additions & 0 deletions dev/Common/Microsoft.Configuration.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

#ifndef __MICROSOFT_CONFIGURATION_H
#define __MICROSOFT_CONFIGURATION_H

namespace Microsoft::Configuration
{
inline bool IsOptionEnabled(PCWSTR name)
{
WCHAR value[1 + 1]{};
if (::GetEnvironmentVariableW(name, value, ARRAYSIZE(value)) == 1)
{
if (*value == L'0')
{
return false;
}
else if (*value == L'1')
{
return true;
}
}
return false;
}
}

#endif // __MICROSOFT_CONFIGURATION_H
22 changes: 21 additions & 1 deletion dev/Deployment/Deployment.idl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Microsoft.Windows.ApplicationModel.WindowsAppRuntime
{
[contractversion(2)]
[contractversion(3)]
apicontract DeploymentContract{};

/// Represents the current Deployment status of the WindowsAppRuntime
Expand Down Expand Up @@ -40,6 +40,26 @@ namespace Microsoft.Windows.ApplicationModel.WindowsAppRuntime
/// WindowsAppSDK main and singleton packages will be shut down forcibly if they are
/// currently in use, when registering the WinAppSDK packages.
Boolean ForceDeployment;

/// If not successful call DebugBreak()
[contract(DeploymentContract, 3)]
Boolean OnError_DebugBreak;

/// If not successful call DebugBreak() if a debugger is attached to the process
[contract(DeploymentContract, 3)]
Boolean OnError_DebugBreak_IfDebuggerAttached;

/// If not successful perform a fail-fast
[contract(DeploymentContract, 3)]
Boolean OnError_FailFast;

/// If not successful show UI
[contract(DeploymentContract, 3)]
Boolean OnError_ShowUI;

/// Do nothing (do not error) if the process lacks package identity
[contract(DeploymentContract, 3)]
Boolean OnNoPackageIdentity_NOOP;
};

/// Used to query deployment information for WindowsAppRuntime
Expand Down
2 changes: 2 additions & 0 deletions dev/Deployment/Deployment.vcxitems
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
<ClCompile Include="$(MSBuildThisFileDirectory)DeploymentActivityContext.cpp" />
</ItemGroup>
<ItemGroup>
<PublicHeaders Include="$(MSBuildThisFileDirectory)DeploymentManagerAutoInitializer.cs" />
<PublicHeaders Include="$(MSBuildThisFileDirectory)DeploymentManagerAutoInitializer.cpp" />
<PublicHeaders Include="$(MSBuildThisFileDirectory)..\common\TerminalVelocityFeatures-DeploymentAPI.h" />
</ItemGroup>
</Project>
41 changes: 40 additions & 1 deletion dev/Deployment/DeploymentInitializeOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,48 @@ namespace winrt::Microsoft::Windows::ApplicationModel::WindowsAppRuntime::implem
{
return m_ForceDeployment;
}

void DeploymentInitializeOptions::ForceDeployment(bool value)
{
m_ForceDeployment = value;
}
bool DeploymentInitializeOptions::OnError_DebugBreak()
{
return m_OnError_DebugBreak;
}
void DeploymentInitializeOptions::OnError_DebugBreak(bool value)
{
m_OnError_DebugBreak = value;
}
bool DeploymentInitializeOptions::OnError_DebugBreak_IfDebuggerAttached()
{
return m_OnError_DebugBreak_IfDebuggerAttached;
}
void DeploymentInitializeOptions::OnError_DebugBreak_IfDebuggerAttached(bool value)
{
m_OnError_DebugBreak_IfDebuggerAttached = value;
}
bool DeploymentInitializeOptions::OnError_FailFast()
{
return m_OnError_FailFast;
}
void DeploymentInitializeOptions::OnError_FailFast(bool value)
{
m_OnError_FailFast = value;
}
bool DeploymentInitializeOptions::OnError_ShowUI()
{
return m_OnError_ShowUI;
}
void DeploymentInitializeOptions::OnError_ShowUI(bool value)
{
m_OnError_ShowUI = value;
}
bool DeploymentInitializeOptions::OnNoPackageIdentity_NOOP()
{
return m_OnNoPackageIdentity_NOOP;
}
void DeploymentInitializeOptions::OnNoPackageIdentity_NOOP(bool value)
{
m_OnNoPackageIdentity_NOOP = value;
}
}
20 changes: 16 additions & 4 deletions dev/Deployment/DeploymentInitializeOptions.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

// Copyright(c) Microsoft Corporation.All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#pragma once
Expand All @@ -16,9 +13,24 @@ namespace winrt::Microsoft::Windows::ApplicationModel::WindowsAppRuntime::implem

bool ForceDeployment();
void ForceDeployment(bool value);
bool OnError_DebugBreak();
void OnError_DebugBreak(bool value);
bool OnError_DebugBreak_IfDebuggerAttached();
void OnError_DebugBreak_IfDebuggerAttached(bool value);
bool OnError_FailFast();
void OnError_FailFast(bool value);
bool OnError_ShowUI();
void OnError_ShowUI(bool value);
bool OnNoPackageIdentity_NOOP();
void OnNoPackageIdentity_NOOP(bool value);

private:
bool m_ForceDeployment{};
bool m_OnError_DebugBreak{};
bool m_OnError_DebugBreak_IfDebuggerAttached{};
bool m_OnError_FailFast{};
bool m_OnError_ShowUI{};
bool m_OnNoPackageIdentity_NOOP{};
};
}
namespace winrt::Microsoft::Windows::ApplicationModel::WindowsAppRuntime::factory_implementation
Expand Down
Loading

0 comments on commit 31519ca

Please sign in to comment.