From c899e31d47adde49ce962072333fb9c0c6ddd65b Mon Sep 17 00:00:00 2001 From: Muhammad Danish <88161975+mdanish-kh@users.noreply.github.com> Date: Sun, 17 Nov 2024 00:45:41 +0500 Subject: [PATCH] Update sandbox dsc sample to use Repair-WinGetPackageManager --- .../full.sandbox.dsc.yaml | 22 +++++++++---------- .../sandbox.dsc.yaml | 21 ++++++++---------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/docs/sampleConfigurations/DscResources/Microsoft.WindowsSandbox.DSC/full.sandbox.dsc.yaml b/docs/sampleConfigurations/DscResources/Microsoft.WindowsSandbox.DSC/full.sandbox.dsc.yaml index b3886b1ec4..b2547ea94c 100644 --- a/docs/sampleConfigurations/DscResources/Microsoft.WindowsSandbox.DSC/full.sandbox.dsc.yaml +++ b/docs/sampleConfigurations/DscResources/Microsoft.WindowsSandbox.DSC/full.sandbox.dsc.yaml @@ -6,8 +6,9 @@ # Mount C:\Sandbox on the local filesystem into the Sandbox filesystem. # # The Logon command performs the following steps in Windows PowerShell: # # 1. Set the execution policy to RemoteSigned # -# 2. Download and install App Installer (WinGet) and it's dependencies # -############################################################################### +# 2. Download and install Microsoft.WinGet.Client PowerShell Module # +# 3. Use Repair-WinGetPackageManager cmdlet to bootstrap WinGet # +############################################################################### properties: resources: @@ -19,24 +20,23 @@ properties: Name: Containers-DisposableClientVM Ensure: Present - resource: Microsoft.WindowsSandbox.DSC/WindowsSandbox - dependsOn: + dependsOn: - WindowsSandbox directives: description: Create Windows Sandbox with Winget installed allowPrerelease: true settings: - Ensure: Present + Ensure: Present HostFolder: C:\Sandbox SandboxFolder: C:\Sandbox LogonCommand: > cmd /c start powershell -NoExit -Command "$progressPreference = 'silentlyContinue'; Write-Host 'Setting execution policy to remote signed...' `n; Set-ExecutionPolicy RemoteSigned -Force; - Write-Host 'Downloading WinGet and its dependencies...' `n; - Invoke-WebRequest -Uri https://aka.ms/getwinget -OutFile Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle; - Invoke-WebRequest -Uri https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile Microsoft.VCLibs.x64.14.00.Desktop.appx; - Invoke-WebRequest -Uri https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/Microsoft.UI.Xaml.2.8.x64.appx -OutFile Microsoft.UI.Xaml.2.8.x64.appx; - Add-AppxPackage Microsoft.VCLibs.x64.14.00.Desktop.appx; - Add-AppxPackage Microsoft.UI.Xaml.2.8.x64.appx; - Add-AppxPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle; + Write-Host "Installing WinGet PowerShell module from PSGallery..."; + Install-PackageProvider -Name NuGet -Force | Out-Null; + Install-Module -Name Microsoft.WinGet.Client -Force -Repository PSGallery | Out-Null; + Write-Host "Using Repair-WinGetPackageManager cmdlet to bootstrap WinGet..."; + Repair-WinGetPackageManager; + Write-Host "Done."; configurationVersion: 0.2.0 diff --git a/docs/sampleConfigurations/DscResources/Microsoft.WindowsSandbox.DSC/sandbox.dsc.yaml b/docs/sampleConfigurations/DscResources/Microsoft.WindowsSandbox.DSC/sandbox.dsc.yaml index 68b986f74c..094bd580c5 100644 --- a/docs/sampleConfigurations/DscResources/Microsoft.WindowsSandbox.DSC/sandbox.dsc.yaml +++ b/docs/sampleConfigurations/DscResources/Microsoft.WindowsSandbox.DSC/sandbox.dsc.yaml @@ -5,9 +5,9 @@ # Run as Administrator # # Mount C:\Sandbox on the local filesystem into the Sandbox filesystem. # # The Logon command performs the following steps in Windows PowerShell: # -# 1. Set the execution policy to RemoteSigned # -# 2. Download and install App Installer (WinGet) and it's dependencies # -############################################################################### +# 1. Download and install Microsoft.WinGet.Client PowerShell Module # +# 2. Use Repair-WinGetPackageManager cmdlet to bootstrap WinGet # +############################################################################### properties: resources: @@ -20,15 +20,12 @@ properties: #WsbFile: LogonCommand: > cmd /c start powershell -NoExit -Command "$progressPreference = 'silentlyContinue'; - Write-Host 'Setting execution policy to remote signed...' `n; - Set-ExecutionPolicy RemoteSigned -Force; - Write-Host 'Downloading WinGet and its dependencies...' `n; - Invoke-WebRequest -Uri https://aka.ms/getwinget -OutFile Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle; - Invoke-WebRequest -Uri https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile Microsoft.VCLibs.x64.14.00.Desktop.appx; - Invoke-WebRequest -Uri https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/Microsoft.UI.Xaml.2.8.x64.appx -OutFile Microsoft.UI.Xaml.2.8.x64.appx; - Add-AppxPackage Microsoft.VCLibs.x64.14.00.Desktop.appx; - Add-AppxPackage Microsoft.UI.Xaml.2.8.x64.appx; - Add-AppxPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle; + Write-Host "Installing WinGet PowerShell module from PSGallery..."; + Install-PackageProvider -Name NuGet -Force | Out-Null; + Install-Module -Name Microsoft.WinGet.Client -Force -Repository PSGallery | Out-Null; + Write-Host "Using Repair-WinGetPackageManager cmdlet to bootstrap WinGet..."; + Repair-WinGetPackageManager; + Write-Host "Done."; #HostFolder: #SandboxFolder: #ReadOnly: false