Skip to content

Commit

Permalink
Resolve Merge Conflict: Main to Develop
Browse files Browse the repository at this point in the history
  • Loading branch information
kythant committed Oct 13, 2022
2 parents aa4b4d9 + 84eb48c commit 8ef7056
Show file tree
Hide file tree
Showing 24 changed files with 210 additions and 461 deletions.
1 change: 1 addition & 0 deletions BuildTransportPackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ foreach($configurationToRun in $configuration.Split(","))
{
foreach($platformToRun in $platform.Split(","))
{
write-host "Moving items to staging directory for Configuration:$configurationToRun and Platform:$platformToRun"
.\build\CopyFilesToStagingDir.ps1 -BuildOutputDir 'BuildOutput' -OverrideDir "$buildOverridePath" -PublishDir "$windowsAppSdkBinariesPath" -NugetDir "$fullNugetPath" -Platform $PlatformToRun -Configuration $ConfigurationToRun
}
}
Expand Down
1 change: 0 additions & 1 deletion NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
</config>
<packageSources>
<clear />
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
<add key="ProjectReunion internal" value="https://microsoft.pkgs.visualstudio.com/ProjectReunion/_packaging/Project.Reunion.nuget.internal/nuget/v3/index.json" />
</packageSources>
<disabledPackageSources>
Expand Down
85 changes: 51 additions & 34 deletions WindowsAppRuntime.sln

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ steps:
- ${{ if eq(parameters.enableLicenseInstall, true) }}:
- task: NuGetToolInstaller@1

- task: NuGetAuthenticate@0
- task: NuGetAuthenticate@1
inputs:
nuGetServiceConnections: 'ProjectReunionInternal'

Expand Down Expand Up @@ -65,7 +65,7 @@ steps:
- task: NuGetToolInstaller@1
- task: NuGetAuthenticate@0
- task: NuGetAuthenticate@1
inputs:
nuGetServiceConnections: 'WindowsES'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:

- task: NuGetToolInstaller@0

- task: NuGetAuthenticate@0
- task: NuGetAuthenticate@1

- task: powershell@2
displayName: 'Create test pfx to sign MSIX test packages (DevCheck)'
Expand Down
6 changes: 3 additions & 3 deletions build/ProjectReunion-BuildFoundation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:

- task: NuGetToolInstaller@1

- task: NuGetAuthenticate@0
- task: NuGetAuthenticate@1
inputs:
nuGetServiceConnections: 'TelemetryInternal'

Expand Down Expand Up @@ -166,7 +166,7 @@ jobs:

- task: NuGetToolInstaller@1

- task: NuGetAuthenticate@0
- task: NuGetAuthenticate@1
inputs:
nuGetServiceConnections: 'TelemetryInternal'

Expand Down Expand Up @@ -246,7 +246,7 @@ jobs:
steps:
- task: NuGetToolInstaller@1

- task: NuGetAuthenticate@0
- task: NuGetAuthenticate@1
inputs:
nuGetServiceConnections: 'TelemetryInternal'

Expand Down
6 changes: 2 additions & 4 deletions build/build-mrt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ steps:
- template: AzurePipelinesTemplates\WindowsAppSDK-InstallWindowsSDK-Steps.yml

- task: NuGetToolInstaller@1
displayName: 'Use NuGet 5.11'
inputs:
versionSpec: 5.11
continueOnError: true

- task: NuGetAuthenticate@1

- task: powershell@2
displayName: 'Create test pfx to sign MSIX test packages (DevCheck)'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#include "pch.h"
#include "Microsoft.Windows.System.EnvironmentManager.h"
#include "Microsoft.Windows.System.EnvironmentManager.g.cpp"
#include "Microsoft.Windows.System.EnvironmentManager.Insights.h"
#include <EnvironmentVariableChangeTracker.h>
#include <EnvironmentVariableChangeTrackerHelper.h>
#include <PathChangeTracker.h>
#include <PathExtChangeTracker.h>
#include <IChangeTracker.h>
#include <TerminalVelocityFeatures-EnvironmentManager.h>


namespace winrt::Microsoft::Windows::System::implementation
{
bool EnvironmentManager::s_HasCheckedIsSupported{};
bool EnvironmentManager::s_IsSupported{};

EnvironmentManager::EnvironmentManager(Scope const& scope)
: m_Scope(scope)
{
Expand Down Expand Up @@ -48,34 +47,21 @@ namespace winrt::Microsoft::Windows::System::implementation
return environmentManager;
}

// Using EM is supported on RS5+.
// Tracking the changes is Windows11+.
bool EnvironmentManager::IsSupported()
{
if (s_HasCheckedIsSupported)
{
return s_IsSupported;
}

PCWSTR c_RegLocationForSupportCheck{ L"SOFTWARE\\Microsoft\\AppModel\\RegistryWriteVirtualization\\ExcludedKeys\\HKEY_CURRENT_USER/Software/ChangeTracker" };

wil::unique_hkey environmentVariablesHKey{};
LSTATUS openResult{ RegOpenKeyEx(HKEY_LOCAL_MACHINE, c_RegLocationForSupportCheck, 0, KEY_READ | KEY_WOW64_64KEY, environmentVariablesHKey.addressof()) };

s_HasCheckedIsSupported = true;
return true;
}

if (openResult == ERROR_SUCCESS)
{
s_IsSupported = true;
}
else if (openResult == ERROR_FILE_NOT_FOUND)
{
s_IsSupported = false;
}
else
bool EnvironmentManager::AreChangesTracked()
{
if (!m_willChangesBeTracked.has_value())
{
THROW_WIN32(openResult);
m_willChangesBeTracked = ShouldChangesBeTracked(m_Scope);
}

return s_IsSupported;
return m_willChangesBeTracked.value();
}

IMapView<hstring, hstring> EnvironmentManager::GetEnvironmentVariables()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#pragma once
#include "Microsoft.Windows.System.EnvironmentManager.g.h"
#include <optional>

using namespace winrt::Windows::Foundation::Collections;

Expand All @@ -23,6 +24,7 @@ namespace winrt::Microsoft::Windows::System::implementation
static Microsoft::Windows::System::EnvironmentManager GetForUser();
static Microsoft::Windows::System::EnvironmentManager GetForMachine();
static bool IsSupported();
bool AreChangesTracked();
IMapView<hstring, hstring> GetEnvironmentVariables();
hstring GetEnvironmentVariable(hstring const& variableName);
void SetEnvironmentVariable(hstring const& name, hstring const& value);
Expand All @@ -33,6 +35,7 @@ namespace winrt::Microsoft::Windows::System::implementation

private:
Scope m_Scope{};
std::optional<bool> m_willChangesBeTracked{};

PCWSTR c_UserEvRegLocation{ L"Environment" };
PCWSTR c_MachineEvRegLocation{ L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment" };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Microsoft.Windows.System
{
[contractversion(1)]
[contractversion(2)]
apicontract EnvironmentManagerContract{};

[contract(EnvironmentManagerContract, 1)]
Expand All @@ -28,5 +28,8 @@ namespace Microsoft.Windows.System
// PathExt Manipulation
void AddExecutableFileExtension(String pathExt);
void RemoveExecutableFileExtension(String pathExt);

[contract(EnvironmentManagerContract, 2)]
Boolean AreChangesTracked{ get; };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(MSBuildThisFileDirectory)EnvironmentVariableChangeTracker.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)EnvironmentVariableChangeTrackerHelper.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)IChangeTracker.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)PathChangeTracker.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)PathExtChangeTracker.h" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

#pragma once
#include <windows.h>
#include <wil/result.h>
#include <Microsoft.Windows.System.EnvironmentManager.h>
#include <AppModel.Identity.h>
#include <Security.IntegrityLevel.h>
#include <Microsoft.Windows.System.EnvironmentManager.Insights.h>
#include <WindowsAppRuntime.SelfContained.h>


using namespace winrt::Microsoft::Windows::System::implementation;

static bool DoesChangeTrackingKeyExist()
{
const auto subKey = std::filesystem::path{ LR"(Software\Microsoft\AppModel\RegistryWriteVirtualization\ExcludedKeys\HKEY_CURRENT_USER/Software/ChangeTracker)" };
wil::unique_hkey keyToChangeTracker{};
return SUCCEEDED(LOG_IF_WIN32_ERROR(RegOpenKeyEx(HKEY_LOCAL_MACHINE, subKey.c_str(), 0, KEY_READ | KEY_WOW64_64KEY, keyToChangeTracker.put())));
}

inline bool ShouldChangesBeTracked(EnvironmentManager::Scope scope)
{
// process scope changes are never tracked becuase they go away when the process ends.
// Non packaged apps don't have identity. No way to revert changes, so don't track them.
// Self-contained deployments aren't eligable for change tracking.
if (scope == EnvironmentManager::Scope::Process || !AppModel::Identity::IsPackagedProcess() || WindowsAppRuntime::SelfContained::IsSelfContained())
{
return false;
}

return DoesChangeTrackingKeyExist();
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ steps:
$pfxPath = (Join-Path $env:Build_SourcesDirectory 'MyCert.pfx')
[System.IO.File]::WriteAllBytes($pfxPath, $certificateBytes)
- task: NuGetAuthenticate@0
- task: NuGetAuthenticate@1
inputs:
nuGetServiceConnections: ${{ parameters.NuGetServiceConnectionName }}
1 change: 0 additions & 1 deletion installer/nuget.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<configuration>
<packageSources>
<clear />
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
<add key="WindowsAppSDK-Dependencies" value="https://pkgs.dev.azure.com/ms/ProjectReunion/_packaging/ProjectReunion-Dependencies/nuget/v3/index.json" />
</packageSources>
<disabledPackageSources>
Expand Down
2 changes: 0 additions & 2 deletions test/EnvironmentManagerTests/CentennialAppxManifest.pkg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,5 @@
</Applications>
<Capabilities>
<rescap:Capability Name="runFullTrust" />
<rescap:Capability Name="packageManagement" />
<rescap:Capability Name="packageQuery" />
</Capabilities>
</Package>
43 changes: 43 additions & 0 deletions test/EnvironmentManagerTests/EnvironmentManagerCentennialTests.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
// Copyright (c) Microsoft Corporation and Contributors. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

// suppress macro redifinition. This is needed to declare tests inline.
#pragma warning(suppress: 4005)
#define INLINE_TEST_METHOD_MARKUP
#include "pch.h"
#include "EnvironmentManagerCentennialTests.h"
#include "EnvironmentVariableHelper.h"
#include "ChangeTrackerHelper.h"
#include "TestSetupAndTeardownHelper.h"
#include <TE.Common.h>
#include <WexTestClass.h>
#include <WindowsAppRuntime.VersionInfo.h>
#include <WindowsAppRuntime.SelfContained.h>

using namespace winrt::Microsoft::Windows;

Expand All @@ -29,6 +36,42 @@ namespace WindowsAppSDKEnvironmentManagerTests
VERIFY_IS_NOT_NULL(environmentManager);
}

void EnvironmentManagerCentennialTests::CentennialTestAreChangesTracked()
{
BEGIN_TEST_METHOD_PROPERTIES()
TEST_METHOD_PROPERTY(L"Data:SelfContained", L"{true, false}")
END_TEST_METHOD_PROPERTIES()

bool isSelfContained{};
VERIFY_SUCCEEDED(WEX::TestExecution::TestData::TryGetValue(L"SelfContained", isSelfContained));

if (!isSelfContained)
{
::WindowsAppRuntime::VersionInfo::TestInitialize(::TP::WindowsAppRuntimeFramework::c_PackageFamilyName, ::TP::WindowsAppRuntimeMain::c_PackageFamilyName);
VERIFY_IS_FALSE(::WindowsAppRuntime::SelfContained::IsSelfContained());

EnvironmentManager forUser{ EnvironmentManager::GetForUser() };
VERIFY_IS_TRUE(forUser.AreChangesTracked());

EnvironmentManager forMachine{ EnvironmentManager::GetForMachine() };
VERIFY_IS_TRUE(forMachine.AreChangesTracked());
}
else
{
::WindowsAppRuntime::VersionInfo::TestInitialize(L"I_don't_exist_package!", L"I_don't_exist_package!");
VERIFY_IS_TRUE(::WindowsAppRuntime::SelfContained::IsSelfContained());

EnvironmentManager forUser{ EnvironmentManager::GetForUser() };
VERIFY_IS_FALSE(forUser.AreChangesTracked());

EnvironmentManager forMachine{ EnvironmentManager::GetForMachine() };
VERIFY_IS_FALSE(forMachine.AreChangesTracked());
}

EnvironmentManager forProcess{ EnvironmentManager::GetForProcess() };
VERIFY_IS_FALSE(forProcess.AreChangesTracked());
}

void EnvironmentManagerCentennialTests::CentennialTestGetEnvironmentVariablesForProcess()
{
EnvironmentManager environmentManager{ EnvironmentManager::GetForProcess() };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,21 @@ namespace WindowsAppSDKEnvironmentManagerTests
return false;
}

::Test::Bootstrap::Setup();
::Test::Bootstrap::SetupPackages();

return true;
}

TEST_CLASS_CLEANUP(ClassUninit)
{
::Test::Bootstrap::Cleanup();
::Test::Bootstrap::CleanupPackages();
return true;
}

TEST_METHOD_SETUP(CentennialWriteEVs)
{
::Test::Bootstrap::SetupBootstrap();

VERIFY_IS_TRUE(TP::IsPackageRegistered_WindowsAppRuntimeFramework());
VERIFY_IS_TRUE(TP::IsPackageRegistered_DynamicDependencyDataStore());
VERIFY_IS_TRUE(TP::IsPackageRegistered_DynamicDependencyLifetimeManager());
Expand All @@ -50,6 +52,7 @@ namespace WindowsAppSDKEnvironmentManagerTests

TEST_METHOD_CLEANUP(CentennialRemoveEVs)
{
::Test::Bootstrap::CleanupBootstrap();
UserCleanup();
MachineCleanup();
return true;
Expand All @@ -59,6 +62,8 @@ namespace WindowsAppSDKEnvironmentManagerTests
TEST_METHOD(CentennialTestGetForUser);
TEST_METHOD(CentennialTestGetForMachine);

TEST_METHOD(CentennialTestAreChangesTracked);

TEST_METHOD(CentennialTestGetEnvironmentVariablesForProcess);
TEST_METHOD(CentennialTestGetEnvironmentVariablesForUser);
TEST_METHOD(CentennialTestGetEnvironmentVariablesForMachine);
Expand Down
Loading

0 comments on commit 8ef7056

Please sign in to comment.