Skip to content

Commit

Permalink
Merge pull request #3209 from microsoft/main
Browse files Browse the repository at this point in the history
Staging - 6/12/24
  • Loading branch information
EricJohnson327 authored Jun 12, 2024
2 parents b74a056 + d69e2cc commit 1ca817f
Show file tree
Hide file tree
Showing 96 changed files with 1,466 additions and 2,050 deletions.
18 changes: 0 additions & 18 deletions DevHome.sln
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevHome.EnvironmentVariable
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DevHome.Telemetry.Native", "telemetry\DevHome.Telemetry.Native\DevHome.Telemetry.Native.vcxproj", "{8EB52F7D-D216-49FF-BF16-DE06E4695950}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WindowsSandboxExtension", "WindowsSandboxExtension", "{4ACF917D-B2CC-4CF2-8EE1-0EBBB52A69F0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindowsSandboxExtension", "extensions\WindowsSandboxExtension\WindowsSandboxExtension.csproj", "{118E20E8-FD8A-40CF-83A5-F912B9187787}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Scripts", "Scripts", "{E768781A-D1F7-4C03-B46D-E76354FAB587}"
ProjectSection(SolutionItems) = preProject
tools\scripts\CaptureDevHomeLogs.ps1 = tools\scripts\CaptureDevHomeLogs.ps1
Expand Down Expand Up @@ -723,18 +719,6 @@ Global
{8EB52F7D-D216-49FF-BF16-DE06E4695950}.Release|x64.Build.0 = Release|x64
{8EB52F7D-D216-49FF-BF16-DE06E4695950}.Release|x86.ActiveCfg = Release|Win32
{8EB52F7D-D216-49FF-BF16-DE06E4695950}.Release|x86.Build.0 = Release|Win32
{118E20E8-FD8A-40CF-83A5-F912B9187787}.Debug|arm64.ActiveCfg = Debug|arm64
{118E20E8-FD8A-40CF-83A5-F912B9187787}.Debug|arm64.Build.0 = Debug|arm64
{118E20E8-FD8A-40CF-83A5-F912B9187787}.Debug|x64.ActiveCfg = Debug|x64
{118E20E8-FD8A-40CF-83A5-F912B9187787}.Debug|x64.Build.0 = Debug|x64
{118E20E8-FD8A-40CF-83A5-F912B9187787}.Debug|x86.ActiveCfg = Debug|x86
{118E20E8-FD8A-40CF-83A5-F912B9187787}.Debug|x86.Build.0 = Debug|x86
{118E20E8-FD8A-40CF-83A5-F912B9187787}.Release|arm64.ActiveCfg = Release|arm64
{118E20E8-FD8A-40CF-83A5-F912B9187787}.Release|arm64.Build.0 = Release|arm64
{118E20E8-FD8A-40CF-83A5-F912B9187787}.Release|x64.ActiveCfg = Release|x64
{118E20E8-FD8A-40CF-83A5-F912B9187787}.Release|x64.Build.0 = Release|x64
{118E20E8-FD8A-40CF-83A5-F912B9187787}.Release|x86.ActiveCfg = Release|x86
{118E20E8-FD8A-40CF-83A5-F912B9187787}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -791,8 +775,6 @@ Global
{1317314E-9BDD-4F1C-A76F-22121637A091} = {FAB6FAA7-ADF4-4B65-9831-0C819915E6E1}
{2E5629CA-0D1B-42B1-8D6E-934A6E1E18D9} = {FAB6FAA7-ADF4-4B65-9831-0C819915E6E1}
{5F9749BC-F34E-4F45-933F-61E0F3ED521F} = {FAB6FAA7-ADF4-4B65-9831-0C819915E6E1}
{4ACF917D-B2CC-4CF2-8EE1-0EBBB52A69F0} = {DCAF188B-60C3-4EDB-8049-BAA927FBCD7D}
{118E20E8-FD8A-40CF-83A5-F912B9187787} = {4ACF917D-B2CC-4CF2-8EE1-0EBBB52A69F0}
{E768781A-D1F7-4C03-B46D-E76354FAB587} = {A972EC5B-FC61-4964-A6FF-F9633EB75DFD}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Expand Down
2 changes: 1 addition & 1 deletion TestingScenarios.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ These are the testing scenarios that need to be validated before shipping a new
1. [Managing Environments](tools/Environments/DevHome.Environments/TestingScenarios/ManageEnvironments.md)
1. [Creating Environment](tools/SetupFlow/DevHome.SetupFlow.UnitTest/TestingScenarios/CreateEnvironment.md)
1. [Setting up an Environment](tools/SetupFlow/DevHome.SetupFlow.UnitTest/TestingScenarios/SetupEnvironment.md)

1. [Quickstart Playground](tools/SetupFlow/DevHome.SetupFlow.UnitTest/TestingScenarios/QuickstartPlayground.md)
28 changes: 11 additions & 17 deletions build/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ extends:
- task: NuGetToolInstaller@1

- task: NuGetAuthenticate@1
inputs:
nuGetServiceConnections: 'DevHomeInternal'

- task: PowerShell@2
displayName: Build SDK
Expand Down Expand Up @@ -109,8 +107,6 @@ extends:
- task: NuGetToolInstaller@1

- task: NuGetAuthenticate@1
inputs:
nuGetServiceConnections: 'DevHomeInternal'

- task: PowerShell@2
displayName: Build Stub Packages
Expand Down Expand Up @@ -139,8 +135,6 @@ extends:
- task: NuGetToolInstaller@1

- task: NuGetAuthenticate@1
inputs:
nuGetServiceConnections: 'DevHomeInternal'

- task: PowerShell@2
displayName: Replace Stubbed Files
Expand All @@ -153,7 +147,7 @@ extends:
artifactName: 'SdkNugetPackage'
targetPath: '$(Pipeline.Workspace)\sdkArtifacts\'

- task: MicrosoftTDBuild.tdbuild-task.tdbuild-task.TouchdownBuildTask@3
- task: MicrosoftTDBuild.tdbuild-task.tdbuild-task.TouchdownBuildTask@4
displayName: Send and Download Localization Files for Artifacts
condition: and(eq(variables['EnableLocalization'], 'true'), eq(variables['UpdateLocalization'], 'true'))
inputs:
Expand All @@ -168,7 +162,7 @@ extends:
appendRelativeDir: true
pseudoSetting: Included

- task: MicrosoftTDBuild.tdbuild-task.tdbuild-task.TouchdownBuildTask@3
- task: MicrosoftTDBuild.tdbuild-task.tdbuild-task.TouchdownBuildTask@4
displayName: Download and Use Localization Files
condition: eq(variables['EnableLocalization'], 'true')
retryCountOnTaskFailure: 2
Expand Down Expand Up @@ -512,7 +506,7 @@ extends:
artifactName: MsixBundle_Release
targetPath: StorePublish

- task: MicrosoftTDBuild.tdbuild-task.tdbuild-task.TouchdownBuildTask@3
- task: MicrosoftTDBuild.tdbuild-task.tdbuild-task.TouchdownBuildTask@4
displayName: Download and Use Localization Files
condition: eq(variables['EnableLocalization'], 'true')
retryCountOnTaskFailure: 2
Expand All @@ -537,11 +531,11 @@ extends:
$Files | % { Move-Item -Verbose $_.Directory $_.Directory.Parent.Parent -EA:Ignore }
pwsh: true

- task: MS-RDX-MRO.windows-store-publish-dev.package-task.store-package@2
- task: MS-RDX-MRO.windows-store-publish-dev.package-task.store-package@3
displayName: 'Create Staging StoreBroker Package'
condition: eq(variables['BuildingBranch'], 'staging')
inputs:
serviceEndpoint: 'DevHomeCanary StoreBroker'
ConnectedServiceNameARM: 'DevHomeCanary StoreBroker ServiceConnection'
sbConfigPath: '$(System.DefaultWorkingDirectory)\build\store\canary\SBConfig.json'
sourceFolder: 'StorePublish'
contents: '*.msixbundle'
Expand All @@ -550,11 +544,11 @@ extends:
outSBName: DevHomeStoreSubmissionPackage
pdpInclude: 'PDP.xml'

- task: MS-RDX-MRO.windows-store-publish-dev.publish-task.store-publish@2
- task: MS-RDX-MRO.windows-store-publish-dev.publish-task.store-publish@3
displayName: 'Publish Staging StoreBroker Package'
condition: eq(variables['BuildingBranch'], 'staging')
inputs:
serviceEndpoint: 'DevHomeCanary StoreBroker'
ConnectedServiceNameARM: 'DevHomeCanary StoreBroker ServiceConnection'
appId: 9MX22N5S7HRD
inputMethod: JsonAndZip
jsonPath: '$(System.DefaultWorkingDirectory)\SBOutDir\DevHomeStoreSubmissionPackage.json'
Expand All @@ -565,11 +559,11 @@ extends:
jsonZipUpdateMetadata: true
updateImages: true

- task: MS-RDX-MRO.windows-store-publish-dev.package-task.store-package@2
- task: MS-RDX-MRO.windows-store-publish-dev.package-task.store-package@3
displayName: 'Create Release StoreBroker Package'
condition: eq(variables['BuildingBranch'], 'release')
inputs:
serviceEndpoint: 'DevHome StoreBroker'
ConnectedServiceNameARM: 'DevHome StoreBroker ServiceConnection'
sbConfigPath: '$(System.DefaultWorkingDirectory)\build\store\preview\SBConfig.json'
sourceFolder: 'StorePublish'
contents: '*.msixbundle'
Expand All @@ -578,11 +572,11 @@ extends:
outSBName: DevHomeStoreSubmissionPackage
pdpInclude: 'PDP.xml'

- task: MS-RDX-MRO.windows-store-publish-dev.publish-task.store-publish@2
- task: MS-RDX-MRO.windows-store-publish-dev.publish-task.store-publish@3
displayName: 'Publish Release StoreBroker Package'
condition: eq(variables['BuildingBranch'], 'release')
inputs:
serviceEndpoint: 'DevHome StoreBroker'
ConnectedServiceNameARM: 'DevHome StoreBroker ServiceConnection'
appId: 9N8MHTPHNGVV
inputMethod: JsonAndZip
jsonPath: '$(System.DefaultWorkingDirectory)\SBOutDir\DevHomeStoreSubmissionPackage.json'
Expand Down
2 changes: 1 addition & 1 deletion common/Environments/CustomControls/CardHeader.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ public BitmapImage HeaderIcon
private static readonly DependencyProperty ActionControlTemplateProperty = DependencyProperty.Register(nameof(ActionControlTemplate), typeof(DataTemplate), typeof(CardHeader), new PropertyMetadata(null));
private static readonly DependencyProperty HeaderCaptionProperty = DependencyProperty.Register(nameof(HeaderCaption), typeof(string), typeof(CardHeader), new PropertyMetadata(null));
private static readonly DependencyProperty HeaderIconProperty = DependencyProperty.Register(nameof(HeaderIcon), typeof(BitmapImage), typeof(CardHeader), new PropertyMetadata(null));
private static readonly DependencyProperty OperationsVisibilityProperty = DependencyProperty.Register(nameof(HeaderCaption), typeof(bool), typeof(CardHeader), new PropertyMetadata(false));
private static readonly DependencyProperty OperationsVisibilityProperty = DependencyProperty.Register(nameof(HeaderCaption), typeof(bool), typeof(CardHeader), new PropertyMetadata(true));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;

namespace DevHome.Common.Environments.Exceptions;

public class EnvironmentNotificationScriptException : Exception
{
public EnvironmentNotificationScriptException(string message)
: base(message)
{
}
}
21 changes: 21 additions & 0 deletions common/Environments/Helpers/ComputeSystemHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks;
using DevHome.Common.Environments.Models;
using DevHome.Common.TelemetryEvents.SetupFlow.Environments;
using Microsoft.Extensions.Hosting;
using Microsoft.UI.Xaml.Media.Imaging;
using Microsoft.Windows.DevHome.SDK;
using Serilog;
Expand Down Expand Up @@ -168,4 +170,23 @@ public static bool RemoveAllItemsAndReplace<T>(ObservableCollection<T> collectio

return false;
}

public static (string DisplayMessage, string DiagnosticText, EnvironmentsTelemetryStatus Status) LogResult(ProviderOperationResult? result, ILogger logger)
{
var telemetryStatus = EnvironmentsTelemetryStatus.Succeeded;

if (result == null)
{
var logErrorMsg = $"The returned result object was null";
logger.Error(logErrorMsg);
return (logErrorMsg, logErrorMsg, EnvironmentsTelemetryStatus.Failed);
}
else if (result.Status == ProviderOperationStatus.Failure)
{
logger.Error(result.ExtendedError, $"Operation failed with error:{result.DiagnosticText}");
telemetryStatus = EnvironmentsTelemetryStatus.Failed;
}

return (result.DisplayMessage, result.DiagnosticText, telemetryStatus);
}
}
43 changes: 41 additions & 2 deletions common/Environments/Helpers/EnvironmentsNotificationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.WinUI.Behaviors;
using DevHome.Common.Environments.Exceptions;
using DevHome.Common.Environments.Models;
using DevHome.Common.Environments.Scripts;
using DevHome.Common.Extensions;
using DevHome.Common.Helpers;
using DevHome.Common.Services;
using DevHome.Common.TelemetryEvents.Environments;
using DevHome.Common.TelemetryEvents.SetupFlow.Environments;
using DevHome.Telemetry;
using Microsoft.UI.Xaml.Controls;
using Microsoft.Windows.DevHome.SDK;
using Serilog;
Expand Down Expand Up @@ -155,6 +160,11 @@ public void DisplayComputeSystemOperationError(string providerDisplayName, strin
[RelayCommand]
private void RestartComputer()
{
TelemetryFactory.Get<ITelemetry>().Log(
"Environment_RestartComputer_Event",
LogLevel.Critical,
new EnvironmentRestartUserEvent());

var startInfo = new ProcessStartInfo
{
WindowStyle = ProcessWindowStyle.Hidden,
Expand Down Expand Up @@ -195,7 +205,9 @@ private void AddUserToHyperVAdminGroupAndEnableHyperV(Notification notification)
startInfo.Verb = "runas";

var process = new Process();
process.StartInfo = startInfo;
process.StartInfo = startInfo;
var telemetryEnablementMap = new Dictionary<FeatureEnablementKind, EnvironmentsTelemetryStatus>();

Task.Run(() =>
{
// Since a UAC prompt will be shown, we need to wait for the process to exit
Expand All @@ -214,37 +226,64 @@ private void AddUserToHyperVAdminGroupAndEnableHyperV(Notification notification)
case 0:
// The script successfully added the user to the Hyper-V Admin Group and enabled the Hyper-V Feature.
_shouldShowHyperVRebootButton = true;
telemetryEnablementMap.Add(FeatureEnablementKind.HyperVFeature, EnvironmentsTelemetryStatus.Succeeded);
telemetryEnablementMap.Add(FeatureEnablementKind.HyperVAdminGroup, EnvironmentsTelemetryStatus.Succeeded);
LogEnablementTelemetry(telemetryEnablementMap);
ShowRestartNotification();
return;
case 2:
// Hyper-V Feature is already enabled and the script successfully added the user to the Hyper-V Admin group.
_shouldShowHyperVRebootButton = true;
telemetryEnablementMap.Add(FeatureEnablementKind.HyperVAdminGroup, EnvironmentsTelemetryStatus.Succeeded);
LogEnablementTelemetry(telemetryEnablementMap);
ShowRestartNotification();
return;
case 3:
// Hyper-V Feature is already enabled and the script failed to add the user to the Hyper-V Admin group.
telemetryEnablementMap.Add(FeatureEnablementKind.HyperVAdminGroup, EnvironmentsTelemetryStatus.Failed);
LogEnablementTelemetry(telemetryEnablementMap, "Failed to enable Hyper-V Feature: exit code 3");
ShowErrorWithRebootAfterExecutionMessage(_stringResource.GetLocalized("UserNotAddedToHyperVAdminGroupMessage"));
return;
case 4:
// The user is already in the Hyper-V Admin group and the script successfully enabled the Hyper-Feature.
telemetryEnablementMap.Add(FeatureEnablementKind.HyperVFeature, EnvironmentsTelemetryStatus.Succeeded);
LogEnablementTelemetry(telemetryEnablementMap);
_shouldShowHyperVRebootButton = true;
ShowRestartNotification();
return;
case 5:
// The user is already in the Hyper-V Admin group and the script failed to enable the Hyper-Feature.
telemetryEnablementMap.Add(FeatureEnablementKind.HyperVFeature, EnvironmentsTelemetryStatus.Failed);
LogEnablementTelemetry(telemetryEnablementMap, "Failed to enable Hyper-V Feature: exit code 5");
ShowErrorWithRebootAfterExecutionMessage(_stringResource.GetLocalized("UnableToEnableHyperVFeatureMessage"));
return;
case 6:
// Display nothing as there is no work to be done
// Display nothing as there is no work to be done, as the feature is enabled and user is in the group.
telemetryEnablementMap.Add(FeatureEnablementKind.HyperVFeature, EnvironmentsTelemetryStatus.NoOperation);
telemetryEnablementMap.Add(FeatureEnablementKind.HyperVAdminGroup, EnvironmentsTelemetryStatus.NoOperation);
LogEnablementTelemetry(telemetryEnablementMap);
return;
}

throw new EnvironmentNotificationScriptException($"HyperV Enablement Script failed with exit code: {process.ExitCode}");
}
catch (Exception ex)
{
_log.Error(ex, "Script failed, we may not have been able to add user to Hyper-V admin group or enable Hyper-V");
telemetryEnablementMap.Add(FeatureEnablementKind.HyperVFeature, EnvironmentsTelemetryStatus.Unknown);
telemetryEnablementMap.Add(FeatureEnablementKind.HyperVAdminGroup, EnvironmentsTelemetryStatus.Unknown);
LogEnablementTelemetry(telemetryEnablementMap, ex.Message);
}

ShowErrorWithRebootAfterExecutionMessage(_stringResource.GetLocalized("UnableToAddUserToHyperVAdminAndEnableHyperVMessage"));
});
}

private void LogEnablementTelemetry(Dictionary<FeatureEnablementKind, EnvironmentsTelemetryStatus> features, string? failureMessage = null)
{
TelemetryFactory.Get<ITelemetry>().Log(
"Environment_FeatureEnablement_Event",
LogLevel.Critical,
new EnvironmentEnablementEvent(features, failureMessage));
}
}
Loading

0 comments on commit 1ca817f

Please sign in to comment.