-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Create SandboxTest script #827
Conversation
I need help with the |
I also need to know where I can get the VCLibs and VCLibsUWP I tried the |
Very cool. Thanks for sharing this prototype script!
Good point. |
People wanting to install Windows Terminal outside of the Store have run into the same issue. An up-to-date version of the dependencies is available in the Store: https://www.microsoft.com/store/productId/9NBLGGH4RV3K Unfortunately, there does not seem to be a way to automate its installation. A manual workaround is described here. |
Good idea! I did it. |
I used https://store.rg-adguard.net/ to download the We can still upload these two
I had read this before, but I didn't get what was the manual workaround. It seems that the Windows Terminal installer now ships the dependencies builtin, and if that's true, this could solve the problem. But an open point is that someone said the installer just tells the Store to download the dependencies automatically, if that's the case this wouldn't help since the Windows Sandbox doesn't have access to the Store. |
Since the script requires winget to be installed, those VCLibs dependencies should also be guaranteed to be present on the host system. I tried building the appx files from C:\ProgramFiles\WindowsApps\Microsoft.VCLibs.. by simply zipping the folders but for some reason the resulting appx files become corrupt. Even taking a valid appx, unzipping and zipping it again, makes them corrupt. Still trying to figure out why. |
@chausner Right. But did you tried with the files in this PR? The binaries are in the branch until I solve that. |
Yes, the current solution works fine (apart from this minor issue https://github.com/felipecassiors/winget-pkgs/pull/1). I was just checking if there is an alternative way to obtain the dependencies. |
The dash character in -ExecutionPolicy was a special character which broke the command.
@chausner Can you please take a look now? I removed the binaries from the branch, and now the script is able to download them if needed. The only thing missing now is the URLs for the VCLibs dependencies (not a problem if we can upload them to somewhere). |
@Xeevis this is intended, we just rely on the status code returned by winget here. Providing a way to not fail on warnings would be a new CLI switch for winget itself, consider opening an Issue there if you think it's good. |
I'll think about adding a switch to skip the validation, though. For now, you can do something like: .\SandboxTest.ps1 { winget install -m 10.0.9.yaml } As long as 10.0.9.yaml is in the current folder. |
@felipecrs have you been able to confirm if this works for the current version of the client with the new manifest schema? I see this PR has been open for a long time. It might be time to consider merging this one :) |
I'm going to try soon, @denelon. |
I think it's good to merge! |
@felipecrs how did you remove the dependency? I'll ask one of the engineers to give this a review :) |
@denelon, well, it seems that the newest version of winget-cli does not depend on that specific |
|
||
Just provide the path to manifest as parameter: | ||
```powershell | ||
.\Tools\SandboxTest.ps1 <path-to-manifest> |
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 kept passing the manifest version file itself and validation kept failing, took me a while to realize this parameter expects the manifest version directory. I'd clarify that here and in the param help
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.
@palenshus Well, my goal was to support the two kinds of manifests to keep backwards compatibility (it was files previously). Since you said you're not from the winget-cli team, it may be better to ask them about it.
@denelon, any suggestion?
If yet we decide to keep accepting both files and folders, the help can be surely enhanced to clarify that.
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.
If you have a singleton manifest you can point to the file, but the directory option works for both cases.
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 see, I was only trying it on multi-file schemas. I'd just make it take a directory in both cases for consistency. Winget will validate the directory and ensure that if the manifestType is singleton, then there's only the one file in there
if (-Not $SkipManifestValidation -And -Not [String]::IsNullOrWhiteSpace($Manifest)) { | ||
Write-Host '--> Validating Manifest' | ||
|
||
if (-Not (Test-Path -Path $Manifest)) { |
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 believe this should have -PathType Container now too?
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.
Depends on the other conversation also.
|
||
Param( | ||
[Parameter(Position = 0, HelpMessage = "The Manifest to install in the Sandbox.")] | ||
[String] $Manifest, |
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.
Shouldn't this be declared mandatory?
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.
The purpose of the script is to be flexible. Some times you just want to open sandbox, have winget installed, the current folder mounted and mess with it freely, this allows:
> .\Tools\SandboxTest.ps1 # works
> .\Tools\SandboxTest.ps1 -Script { winget install git; Update-Environment; git --version } # also works, no manifest
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 see, I didn't realize that was an intended purpose, makes sense
|
||
Get-ChildItem $tempFolder -Recurse -Exclude $dependencies.fileName | Remove-Item -Force -Recurse | ||
|
||
if (-Not [String]::IsNullOrWhiteSpace($Manifest)) { |
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.
Aside from making this mandatory in the params, I'd check this once up top and fail out if it's whitespace, then you don't have to keep checking it
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.
Also depends on the other conversation, I guess.
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.
Leaving manifest optional is fine
Tools/SandboxTest.ps1
Outdated
|
||
# Create Bootstrap script | ||
|
||
# See: https://stackoverflow.com/a/14382047/12156188 |
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'd rename this for a little more clarity. Maybe Update-EnvironmentVariables?
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.
Also, this implementation seems a little less fraught to me? https://stackoverflow.com/a/22670892/892770
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.
Update-EnvironmentVariables
Well, it's really a long string, especially if you consider that it will be typed manually. But that's how PowerShell is, I agree with this change.
Also, this implementation seems a little less fraught to me? https://stackoverflow.com/a/22670892/892770
Definitely. I don't know why I picked the first one, but I'll try and if it works I'll switch.
Tools/SandboxTest.ps1
Outdated
|
||
|
||
|
||
|
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.
Why so much whitespace?
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.
Because of this (the progress bar stays on the screen even after the completion):
One option would be to hide the progress bar though, but I just wanted to make the script as transparent as possible. I even though about turning on the PowerShell debug feature to output each command being runned, but it turned out to be too noisy.
What do you think?
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.
Gotcha, keep it then no prob
Very cool, this is super impressive! Just got a few comments here and there |
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 so much for the comments, I'll work on them, but a few I still require some inputs.
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.
Looks good to me
The library dependencies have been removed.
PS: check this comment if you want to use it before it gets merged.
Description
A new PowerShell script to test the installation of any Manifest in Windows Sandbox.
Usage
Examples
A GIF is worth a thousand words.
To-do list
Download
winget
.Appx
files on the fly, including the dependencies such as theVCLibs
(and remove them from git, of course)Validate Manifest file with
winget validate
before pushing to Sandbox testInstall
winget
in SandboxRun
winget install -m
with the provided manifest file in SandboxAdd ability to run the custom script as the last step in Sandbox
Automatically refresh the environment variables after installing the Manifest
Close Windows Sandbox automatically if needed
Provide a way to specify which folder to mount, default is the current
Fixes microsoft/winget-cli#253, despite personally I would love to see this integrated into
winget-cli
itself, so at least users would not need to clone the repository before testing.Microsoft Reviewers: Open in CodeFlow