-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
WIP Setup Windows Sandbox #11060
base: master
Are you sure you want to change the base?
WIP Setup Windows Sandbox #11060
Conversation
@mstv @RussKie @gerhardol Please take for a spin. I am going to add a readme describing this in more detail to the pr but the idea is to be able to do clean machine testing in windows sandbox. It will configure the sandbox based on the setup and setup-repo scripts. This allows a developer to modify initial state as desired for the tests. They can modify the scripts to have whatever initial repo state. Key points:
|
f423b8c
to
b9a1c3b
Compare
This PR is the pulled out work from #10473 to provide a basic Windows sandbox functionality. While the changes in the GPG pull request adds to the sandbox work to show GPG testing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot test it due to an error popup (MessageBox) - although I can run WSB from Start menu.
As unfortunately usual, the error message does not contain the "specified" path!
---------------------------
Windows-Sandbox
---------------------------
An error occurred during sandbox configuration. This can occur if invalid settings were passed to the sandbox.
Error 0x80070003. The system cannot find the specified path.
#> | ||
|
||
#required to turn on windows feature | ||
#requires -RunAsAdministrator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this mandatory if WSB is installed?
I can run WSB from Start menu without UAC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is if it has to enable the feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see if I can move it to the enable step area.
StartWSB | ||
} | ||
else { | ||
Enable-WindowsOptionalFeature -Online -FeatureName Containers-DisposableClientVM -NoRestart |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(My system needed to restart.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I'll add to documentation that it attempts to not require a restart but may require one.
& $PSScriptRoot\Setup-Repo.ps1 | ||
|
||
Copy-Item .\setup.log $TestResults | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
Copy-Item .\setup.log $TestResults | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scripts/wsb/setup.ps1
Outdated
Update-SessionEnvironment | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you confirm you have the folders in Sandbox.wsb file mentioned. I do need to add a message around running script to get psr if someone just double clicks wsb file and wsb can't find psr.exe. Thanks for testing. Love works on my machine fun. |
I double checked the existence of the 4 folders before. I forgot to mention my environment
This took long, but succeeded including
|
Sandbox.wsb
Outdated
<HostFolder>.\scripts\wsb</HostFolder> | ||
<ReadOnly>true</ReadOnly> | ||
</MappedFolder> | ||
<MappedFolder> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😉
<MappedFolder> | |
<MappedFolder> |
Yes. It's not a quick tool. It is for repeatable clean machine testing. So yes it has to do setup each time. Relative paths seem to work in wsb in windows 11. I might have to code it to generate the correct full paths into the wsb file. It's supposed to run powershell as admin in the sandbox I'll see if I can just adjust the paths so it sees psr.exe in the wsb folder. Thanks for testing. I'll tweak based on your feedback. |
fe36a86
to
92e1ca6
Compare
92e1ca6
to
23bb023
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @vbjay. I'm still planning to look at this but my workload is pretty high atm.
23bb023
to
fbadb01
Compare
Ok @mstv . Can you run through another run. I still have to think about the admin piece. The get optional features requires it and I am trying to make it to where it sets it up for you. I may break apart into setup dev environment script and a warning to setup if sandbox feature not setup. But I kinda liked the idea of the one script just figuring it out for you and installing the feature if needed. Also try the same script in the branch for #10473 The goal is this pr is merged before that branch. But I think I got it to where it won't give you issues with the relative paths and such. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It silently fails to run the LogonCommand
.
Manual start of powershell
results in:
Version v4.0.30319 of the .NET Framework is not installed and it is required to run version 3 of Windows PowerShell.
Windows 10 Pro 22H2 build 19045.3208
Windows Feature Experience Pack 1000.19041.1000.0
StartWSB | ||
} | ||
else { | ||
Write-Error "Must run script as Administrator to install Containers-DisposableClientVM windows optional feature. Once installed, it is not required." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write-Error "Must run script as Administrator to install Containers-DisposableClientVM windows optional feature. Once installed, it is not required." | |
Write-Error "Must run script as Administrator to install Containers-DisposableClientVM windows optional feature. Once installed, it is not required." |
Unfortunately, the latter is not true for the current script anyway (as you mentioned). Get-WindowsOptionalFeature
would need to be skipped because it requires higher privileges. A regarding message appears in addition to the misleading "Unsupported Operating System: Windows 10 Pro or Enterprise 1903 or greater required."
else { | ||
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) | ||
if ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { | ||
Write-Warning "A windows restart may be required. If it fails to start reboot and attempt again." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write-Warning "A windows restart may be required. If it fails to start reboot and attempt again." | |
Write-Warning "A windows restart may be required. If it fails to start, reboot and attempt again." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It silently fails to run the LogonCommand.
Manual start of powershell results in:
Version v4.0.30319 of the .NET Framework is not installed and it is required to run version 3 of Windows PowerShell.
Lovely. It may be a version of this. https://answers.microsoft.com/en-us/windows/forum/all/windows-sandbox-cant-run-powershell/21d50264-b2e8-4eca-b081-a8cc4778e86d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well after the Tuesday update (build 19045.3324).
8bd32c3
to
1f3c7ca
Compare
See #11060 (comment) |
1f3c7ca
to
248abca
Compare
Proposed changes
Windows Sandbox: https://learn.microsoft.com/en-us/windows/security/application-security/application-isolation/windows-sandbox/windows-sandbox-overview
See sample output from
TestResults.zip
Test methodology
Test environment(s)
Merge strategy
Merge commit. (PR submitter to rebase and squash before merges).
✒️ I contribute this code under The Developer Certificate of Origin.