Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dev Environments feature into main from feature branch #2346

Merged
merged 32 commits into from
Mar 7, 2024

Conversation

bbonaby
Copy link
Contributor

@bbonaby bbonaby commented Mar 5, 2024

Summary of the pull request

This PR moves the Dev Environment code from the feature branch to Dev Home main. The move includes the following

  1. Hyper-V Dev Home extension
    1.1. The extension includes separate projects for the DevSetupAgent service and DevSetupEngine COM server. These allow configuration to be done within a virtual machine running the Windows OS.
  2. An environments tool page that allows users to manage their Dev Environments
  3. A new Setup target flow that allows users to configure their environments in the machine configuration page.
  4. DevHome.Common and the Hyper-V extension now use the new Dev SDK version.

Note: The Azure extension will house the code for the Dev Box environment and a second PR to move that code from a feature branch within the azure extension, to the azure extensions main branch will happen after this one is complete.

References and relevant issues

Detailed description of the pull request / Additional comments

Validation steps performed

Rebuilt Dev Home and confirmed all preview and canary versions of extensions are still working. Github extension and Azure extension all still clone repositories and allow users to login through their respective flows. Core widgets are also still working as expected. Also confirmed that I can still install apps.

The DevHome Common project now uses the new published Dev Home SDK: 0.200.427

PR checklist

bbonaby and others added 21 commits February 8, 2024 16:44
* Add initial code from private branch that will be shared between the setup flow and the Dev environments tool page. PRs: from private ADO repo: https://dev.azure.com/microsoft/Dart/_git/DevHome?version=GBDevEnv

* add changes to the setup flow for dev environment configuration PRS: from private ADO repo: https://dev.azure.com/microsoft/Dart/_git/DevHome?version=GBDevEnv

* Add dev environments management tool page from private ADO repo: https://dev.azure.com/microsoft/Dart/_git/DevHome?version=GBDevEnv

* fix conflicts and stylecop errors due to update from merge with main

---------

Co-authored-by: Huzaifa Danish <[email protected]>
…ironments feature branch (#2246)

* Add Hyper-v extension to Dev Home from Private Hyper-v extension branch: PRS https://github.com/microsoft/DevHomeHyperVExtension

* Merge changes from Dev Home main and fix style cop errors
…Adaptive Cards to Hyper-V Configure command. (#2289)
…d DevSetupAgent_*.zip to MSIX package. (#2325)

* Add WaitForLogin and Credentials Adaptive Cards

* Address review comments.

* New VS solution for DevSetupAgent

* Add BuildDevSetupAgentHelper script

* Fix x86 DevSetupAgent to work on x64 OS.
Create DevSetupAgent zip for different VM architectures.
Fixed build scripts and HyperVExtension.csproj to include DevSetupAgent zip file into Dev Home MSIX package.

* Remove old comment.

* Fix a comment.
…ent. (#2321)

* initial code

* update messaging and adaptive cards

* remove added method

* update strings and names

* update based on initial comments and update IsHyperVModuleLoaded with new work around that doesn't involve installing using Install-Module which installs from PsGallery

* improve wording

* fix merge conflicts
* update feature branch to latest sdk

* update InputJson to inputJson

* update with latest changes
* add updates to ui

* fix crashes due to resource name mismatch

* update feature branch to latest sdk

* update InputJson to inputJson

* update with latest changes

* update

* update to remove duplicate, resize shimmer, remove id from winget file since its not needed, and add comments

* Re-add correct adaptive host file for correct theming, address some initial comments, update loading page to allow scrolling when there are tasks and actions in the action center. Fix error message spelling.

* improve setup target loading page progress messaging

* Fix git clone's dependsOn Id to match our new Ids for setup target flow
Copy link
Contributor

@EricJohnson327 EricJohnson327 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking checkin until core team has a chance to look tomorrow.

@@ -105,6 +106,9 @@ public App()
services.AddSingleton<IAppInstallManagerService, AppInstallManagerService>();
services.AddSingleton<IPackageDeploymentService, PackageDeploymentService>();
services.AddSingleton<IScreenReaderService, ScreenReaderService>();
services.AddSingleton<IComputeSystemService, ComputeSystemService>();
services.AddSingleton<IComputeSystemManager, ComputeSystemManager>();
services.AddSingleton<ToastNotificationService>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dkbennett do we have toast notifications in Dev Home core already? I just want to make sure we don't have 2 solutions now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what it's worth we added this here now because we needed a way to tell the user that they arent in the Hyper-V admin group when they open the environments tool page or the "Setup a target" flow in machine configuration. (You can't do any Hyper-V admin functionality unless you are in an elevated process or you're in the Hyper-v admin group). E.g the Hyper-V manager in the Windows OS actually runs elevated, we just don't see the UAC.

But we have plans to actually create an elevated process to add the user to this group, without the need to show a toast notification (work is to be done before Build), in which case we'd remove this. Though I know there are other ways to tell the user this without the need for the toast notification, it's what we ended up doing for now. So, in the end, this is only temporary. If David already has a way to send notifications, we can use that. Otherwise, just know this is temporary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is totally fine. I know David added notifications to the extensions, but I wanted to check if there was existing code in Dev Home to do this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding an interface for this service for mock-ability

@krschau krschau force-pushed the microsoftfeature/dev-environments branch from 754bae2 to 94d116b Compare March 5, 2024 15:49
}

if (-not $BypassWarning) {
Write-Host @"
Copy link
Collaborator

@krschau krschau Mar 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an FYI (I looked this up recently) powershell scripts conventionally have 4 space indents (not blocking)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Number of spaces per intent is a religion, we just need to agree what we believe in 😄. The existing Build.ps1 and BuildSDKHelper.ps1 have 2 space intents. This script follows what we already have.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We updated Build.ps1 recently to have 4, but I understand we're quite inconsistent now. This was more of a "we came to a conclusion that we'll try to follow going forward" note. (Not that everyone's happy with that conclusion 😄 )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's 4 now, then this one can be changed. I have no problem with any reasonable number (I worked for a company where it was 3).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 is simply ridiculous :) I'm the one that doesn't like 4 spaces, but I concede it's become the standard.

@@ -110,42 +114,34 @@ private async Task<bool> IsValidDevHomeExtension(Package package)
if (package.Id.FullName == extension.Package.Id.FullName)
{
var (devHomeProvider, classId) = await GetDevHomeExtensionPropertiesAsync(extension);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be classIds now?

src/Services/ExtensionService.cs Show resolved Hide resolved

<ItemGroup>
<PackageReference Include="CommunityToolkit.WinUI.Collections" Version="8.0.240109" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240227000" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove WinAppSDK, you get it free for including DevHome.Common (and we don't want more places to have to keep updated). You can also remove Converters, Shimmer, Animations, and Segmented.


<ItemGroup>
<ProjectReference Include="..\..\..\common\DevHome.Common.csproj" />
<ProjectReference Include="..\..\..\logging\DevHome.Logging.csproj" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove Logging, you get it for free with Common

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not entirely free. It brings cross-project dependencies that we don’t want to have (at least not now). Part of the projects in this PR are built separately from the main solution and don’t go into Dev Home’s output directly, but rather compressed into a .zip file to be deployed on a Hyper-V VM. The additional cross-project dependencies make building those projects more difficult. Also, it’s likely we will change .NET version for those projects from .NET8 to .NET Framework to reduce output size since .NET Framework is pre-installed on Windows. That can introduce additional problems if we can change some of the code to be compatible with .NET Framework.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose I shouldn't have said "free", but including DH.Common makes DH.Logging redundant. I would understand if you wanted Logging without the rest of Common, but since you already have Common, I'm not sure what Logging gets you.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually tried to remove it about a week ago and it created more problems with those special projects that I had time to fix.

Comment on lines +243 to +246

<ItemGroup>
<Folder Include="NewFolder\" />
</ItemGroup>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guessing this doesn't exist and should be removed.

</ItemGroup>

<ItemGroup>
<Folder Include="Converters\" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converters, Models, and Templates all don't exist, remove.

<devEnvConverters:CardStateToLocalizedTextConverter x:Key="CardStateToLocalizedTextConverter"/>
</UserControl.Resources>

<Grid
Copy link
Collaborator

@krschau krschau Mar 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation in this file is messed up (not blocking)

<ProjectReference Include="..\Telemetry\HyperVExtension.Telemetry.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.4">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using the .net analyzers you get for free, that's what the rest of Dev Home does (see that Directory.Build.Props has true)

".NET compiler platform (Roslyn) analyzers inspect your C# or Visual Basic code for code quality and style issues. Starting in .NET 5, these analyzers are included with the .NET SDK and you don't need to install them separately. If your project targets .NET 5 or later, code analysis is enabled by default. If your project targets a different .NET implementation, for example, .NET Core, .NET Standard, or .NET Framework, you must manually enable code analysis by setting the EnableNETAnalyzers property to true."
https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/overview?tabs=net-8

Is there a specific reason you chose 7.0.4 and not 8.0.0?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason other than this project was started separately from Dev Home as an extension that would have its own GitHub repo and used whatever version of Microsoft.CodeAnalysis.NetAnalyzers existed at that time. So, it can be removed now.

Comment on lines +38 to +40
<ItemGroup>
<Folder Include="Assets\" />
</ItemGroup>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't exist, remove.

</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240227000" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Included in HyperVExtension.Common, remove here. Microsoft.Extensions.Hosting too.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you do a scan for these in all the projects under HyperVExtension? GH is really laggy with a PR this big and me trying to jump between files is not working well 😅

@krschau
Copy link
Collaborator

krschau commented Mar 5, 2024

The only thing I'm really blocking on above is the missing null check, but if you could also remove some of the references to things that don't exist, I think that would be a pretty quick thing to do.

As an FYI, the codebase uses spaces instead of tabs (.sln files are the only ones that don't follow this) and crlf line endings instead of lf. I pushed these changes just to take it off your plate, hope I didn't step on any toes.

The additional things we would like to see here (that we've agreed will go in separately) are

Copy link
Contributor

@EricJohnson327 EricJohnson327 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pending the null fix Kristen mentioned and the github build pipeline break, code looks good to me. Please fix those before checking in.

{
private readonly IHost _host;

public DevAgentService(IHost host)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are IHostChannel and IRequestManager singleton? If so avoid directly injecting IHost, instead directly inject IHostChannel and IRequestManager. If they are transient, consider registering a factory class/function.

@@ -105,6 +106,9 @@ public App()
services.AddSingleton<IAppInstallManagerService, AppInstallManagerService>();
services.AddSingleton<IPackageDeploymentService, PackageDeploymentService>();
services.AddSingleton<IScreenReaderService, ScreenReaderService>();
services.AddSingleton<IComputeSystemService, ComputeSystemService>();
services.AddSingleton<IComputeSystemManager, ComputeSystemManager>();
services.AddSingleton<ToastNotificationService>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding an interface for this service for mock-ability

@@ -176,6 +183,12 @@ protected async override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventA

private void OnActivated(object? sender, AppActivationArguments args)
{
if (args.Kind == ExtendedActivationKind.ToastNotification)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can leverage IActivationHandler here by adding a new activation handler for the type ToastNotificationActivatedEventArgs.

Check ProtocolActivationHandler.cs for an example.

@@ -38,6 +41,23 @@ public ConfigurationUnitResult(ElevatedConfigureUnitTaskResult result)
ErrorDescription = result.ErrorDescription;
}

public ConfigurationUnitResult(SDK.ApplyConfigurationUnitResult result)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a permanent SDK change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea for the Dev Environments project we allow environments to be configured with WinGet configure by passing a config file as a string to the extension. However from an extensions point of view, there are times where they'd need to actually translate what they get from WinGet on a remote machine e.g a local VM or over the network back to the Dev Home extension. For example this can be done through strings, but now Dev Home and the extension need a common way to understand what is going on with the configuration (interpreting this string). So, we created a subset of WinGet interfaces/runtime classes in the SDK that extensions can then translate WinGet progress and results into, then send back to Dev Home via the SDK. From there once we receive it in Dev Home. We can reuse some of the classes we're using currently in the Configuration flow.

John from the WinGet team was on board with using a subset of the winget interfaces for this purpose. I can share the api review doc with you if you like.

@@ -75,13 +76,15 @@ public partial class PackageViewModel : ObservableObject
IWinGetPackage package,
IThemeSelectorService themeSelector,
IScreenReaderService screenReaderService,
IHost host)
IHost host,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove host here and just keep the orchestrator

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, I can update this in a future PR

Copy link
Collaborator

@krschau krschau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing my block

@bbonaby bbonaby merged commit 1200e38 into main Mar 7, 2024
4 checks passed
@krschau krschau deleted the microsoftfeature/dev-environments branch August 14, 2024 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add VM and Cloud Environment Support to Dev Home
6 participants