Add PowerShell script and a helper class to deploy DevSetupAgent service to a Hyper-V VM.#2261
Conversation
…vice to a Hyper-V VM.
HyperVExtension/src/HyperVExtension/Helpers/DevSetupAgentDeploymentHelper.cs
Show resolved
Hide resolved
HyperVExtension/src/HyperVExtension/Helpers/DevSetupAgentDeploymentHelper.cs
Show resolved
Hide resolved
HyperVExtension/src/HyperVExtension/Helpers/DevSetupAgentDeploymentHelper.cs
Outdated
Show resolved
Hide resolved
|
|
||
| # Stop and remove previous version of DevSetupAgent service if it exists | ||
| $service = Get-Service -Name $using:DevSetupAgentConst -ErrorAction SilentlyContinue | ||
| if ($service -ne $null) |
There was a problem hiding this comment.
Its best practice to put the $null on the left side of the comparison for PowerShell:
https://learn.microsoft.com/en-us/powershell/scripting/learn/deep-dives/everything-about-null?view=powershell-7.2#checking-for-null , so I think we can update it here and also anywhere below.
| if ($service -ne $null) | |
| if ($null -ne $service) |
There was a problem hiding this comment.
Seems like it should be just "if ($service)".
HyperVExtension/src/HyperVExtension/Helpers/DevSetupAgentDeploymentHelper.cs
Outdated
Show resolved
Hide resolved
HyperVExtension/src/HyperVExtension/Helpers/DevSetupAgentDeploymentHelper.cs
Show resolved
Hide resolved
HyperVExtension/src/HyperVExtension/Helpers/DevSetupAgentDeploymentHelper.cs
Show resolved
Hide resolved
| var userName = "LocalAdmin"; | ||
| var pwd = new NetworkCredential(string.Empty, "<>").SecurePassword; | ||
| deploymentHelperMock.Object.DeployDevSetupAgent(userName, pwd); |
There was a problem hiding this comment.
I think Eric was saying something about cred scan in the pipelines not liking the use of even test usernames and passwords. So just in case we should probably do it like this, to obfuscate it a little more:
| var userName = "LocalAdmin"; | |
| var pwd = new NetworkCredential(string.Empty, "<>").SecurePassword; | |
| deploymentHelperMock.Object.DeployDevSetupAgent(userName, pwd); | |
| deploymentHelperMock.Object.DeployDevSetupAgent("LocalAdmin", new NetworkCredential(string.Empty, "<>").SecurePassword); |
There was a problem hiding this comment.
How does it obfuscate it? Or do you know how that detection works? Those values don't matter as you have to change them into real ones. I can just use string.empty.
There was a problem hiding this comment.
I was thinking more that the cred scan would be looking for variable names like "username" and "pwd" within a function.
…ymentHelper.cs Co-authored-by: Branden Bonaby <105318831+bbonaby@users.noreply.github.com>
| try | ||
| { | ||
| Write-Host ""Stopping DevSetupAgent service"" | ||
| Write-Progress -Activity $using:activity -Status ""Stopping DevSetupAgent service $destinationPath"" -PercentComplete 30 |
There was a problem hiding this comment.
oh interesting I had assumed a user could pause any service if they had permission.
* add initial SDK changes (#2209) * Add UX code from private ADO branch to public feature branch (#2241) * 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 <modanish@microsoft.com> * Move Hyper-V extension code from private repository to public dev environments 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 * Initial implementation of IComputeSystem::ApplyConfiguration for HyperV extension. (#2258) * Add environments to experimentation (#2260) * Add PowerShell script and a helper class to deploy DevSetupAgent service to a Hyper-V VM. (#2261) * Hyper-V extension: Add "Ask for VM credentials" and "Wait for logon" Adaptive Cards to Hyper-V Configure command. (#2289) * Changes to make DevSetupEngine work with .NET 8 (#2308) * Build DevSetupAgent separately from the main Dev Home solution and add 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. * Update setup target flow to allow for configuration of a dev environment. (#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 dev environments feature branch with latest idl changes (#2334) * update feature branch to latest sdk * update InputJson to inputJson * update with latest changes * Update environments page UX (#2320) * 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 * Update build scripts to build DevSetupAgent in Azure official build. (#2339) * update dev home to use new SDK version and other projects to use win app sdk v1.5 to prevent build issues (#2344) * Fix PS DevSetupAgent deployment script. (#2345) * remove classes that don't need to be added * Change all tabs to spaces * Update tools directory to use crlf * Update HyperVExtension directory to use crlf * Update common/Environments directory to use crlf * Update more in common directory to use crlf * [Hyper-V extension]: Fixes for DevSetupEngine registration, Configure progress reporting, and GitHub build. (#2348) * remove s that was added from a previous commit causing build to fail * fix tests for build * update malformed configuration string to allow arm64 to build --------- Co-authored-by: Huzaifa Danish <modanish@microsoft.com> Co-authored-by: sshilov7 <51001703+sshilov7@users.noreply.github.com> Co-authored-by: Kristen Schau <47155823+krschau@users.noreply.github.com>
Add PowerShell script and a helper class to deploy DevSetupAgent service to a Hyper-V VM.
Summary of the pull request
Provided Hyper-V admin credentials and a path to DevSetupAgent (folder with binaries or a .zip file) it will
Add an integration test that can call DevSetupAgentDeploymentHelper with user's credential and path to DevSetupAgent to deploy it on a VM (requires to have a VM created and modify code to enter user's password at the moment).
Small changes to existing PowerShell helpers to custom PS function work (add useLocalScope parameter).
Validation steps performed
Ran new test, verified that binaries were deployed on the target VM.
Manual debugging of C# and PS code.
PR checklist