Skip to content

Commit 5733b47

Browse files
authored
Merge pull request #222 from Evilazaro:update/CustomTasks
Update/CustomTasks
2 parents 150d8be + c78f168 commit 5733b47

File tree

7 files changed

+202
-108
lines changed

7 files changed

+202
-108
lines changed

.configuration/devcenter/tasks/git-clone/main.ps1

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,9 @@ function InstallWinGet {
151151
pwsh.exe -MTA -Command "Set-PSRepository -Name PSGallery -InstallationPolicy Trusted"
152152

153153
# check if the Microsoft.Winget.Client module is installed
154-
$wingetClientPackage = Get-Module -ListAvailable -Name Microsoft.WinGet.Client | Where-Object { $_.Version -ge "1.9.2411" }
154+
$wingetClientPackage = pwsh.exe -Command "Get-Module -ListAvailable -Name Microsoft.WinGet.Client | Where-Object { `$_.Version -ge '1.9.2411' }"
155155
if (!($wingetClientPackage)) {
156156
Write-Host "Installing Microsoft.Winget.Client"
157-
Install-Module Microsoft.WinGet.Client -Scope $PsInstallScope
158157
pwsh.exe -MTA -Command "Install-Module Microsoft.WinGet.Client -Scope $PsInstallScope"
159158
Write-Host "Done Installing Microsoft.Winget.Client"
160159
}
@@ -163,7 +162,7 @@ function InstallWinGet {
163162
}
164163

165164
# check if the Microsoft.WinGet.Configuration module is installed
166-
$wingetConfigurationPackage = Get-Module -ListAvailable -Name Microsoft.WinGet.Configuration | Where-Object { $_.Version -ge "1.8.1911" }
165+
$wingetConfigurationPackage = pwsh.exe -Command "Get-Module -ListAvailable -Name Microsoft.WinGet.Configuration | Where-Object { `$_.Version -ge '1.8.1911' }"
167166
if (!($wingetConfigurationPackage)) {
168167
Write-Host "Installing Microsoft.WinGet.Configuration"
169168
pwsh.exe -MTA -Command "Install-Module Microsoft.WinGet.Configuration -AllowPrerelease -Scope $PsInstallScope"
@@ -187,18 +186,37 @@ function InstallWinGet {
187186
if ($PsInstallScope -eq "CurrentUser") {
188187
# Under a user account, the way to materialize winget.exe and make it work is by installing DesktopAppInstaller appx,
189188
# which in turn may have Xaml and VC++ redistributable requirements.
189+
190+
$architecture = "x64"
191+
if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") {
192+
$architecture = "arm64"
193+
}
194+
195+
$msVCLibsPackage = Get-AppxPackage -Name "Microsoft.VCLibs.140.00.UWPDesktop" | Where-Object { $_.Version -ge "14.0.30035.0" }
196+
if (!($msVCLibsPackage)) {
197+
# Install Microsoft.VCLibs.140.00.UWPDesktop
198+
try {
199+
Write-Host "Installing Microsoft.VCLibs.140.00.UWPDesktop"
200+
$MsVCLibs = "$env:TEMP\$([System.IO.Path]::GetRandomFileName())-Microsoft.VCLibs.140.00.UWPDesktop"
201+
$MsVCLibsAppx = "$($MsVCLibs).appx"
202+
203+
Invoke-WebRequest -Uri "https://aka.ms/Microsoft.VCLibs.$($architecture).14.00.Desktop.appx" -OutFile $MsVCLibsAppx
204+
Add-AppxPackage -Path $MsVCLibsAppx -ForceApplicationShutdown
205+
Write-Host "Done Installing Microsoft.VCLibs.140.00.UWPDesktop"
206+
} catch {
207+
Write-Host "Failed to install Microsoft.VCLibs.140.00.UWPDesktop"
208+
Write-Error $_
209+
}
210+
}
211+
190212
$msUiXamlPackage = Get-AppxPackage -Name "Microsoft.UI.Xaml.2.8" | Where-Object { $_.Version -ge "8.2310.30001.0" }
191213
if (!($msUiXamlPackage)) {
192214
# install Microsoft.UI.Xaml
193215
try {
194216
Write-Host "Installing Microsoft.UI.Xaml"
195-
$architecture = "x64"
196-
if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") {
197-
$architecture = "arm64"
198-
}
199-
$MsUiXaml = "$env:TEMP\$([System.IO.Path]::GetRandomFileName())-Microsoft.UI.Xaml.2.8.7"
217+
$MsUiXaml = "$env:TEMP\$([System.IO.Path]::GetRandomFileName())-Microsoft.UI.Xaml.2.8.6"
200218
$MsUiXamlZip = "$($MsUiXaml).zip"
201-
Invoke-WebRequest -Uri "https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.8.7" -OutFile $MsUiXamlZip
219+
Invoke-WebRequest -Uri "https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.8.6" -OutFile $MsUiXamlZip
202220
Expand-Archive $MsUiXamlZip -DestinationPath $MsUiXaml
203221
Add-AppxPackage -Path "$($MsUiXaml)\tools\AppX\$($architecture)\Release\Microsoft.UI.Xaml.2.8.appx" -ForceApplicationShutdown
204222
Write-Host "Done Installing Microsoft.UI.Xaml"
@@ -209,7 +227,7 @@ function InstallWinGet {
209227
}
210228

211229
$desktopAppInstallerPackage = Get-AppxPackage -Name "Microsoft.DesktopAppInstaller"
212-
if (!($desktopAppInstallerPackage) ) {
230+
if (!($desktopAppInstallerPackage) -or ($desktopAppInstallerPackage.Version -lt "1.22.0.0")) {
213231
# install Microsoft.DesktopAppInstaller
214232
try {
215233
Write-Host "Installing Microsoft.DesktopAppInstaller"
@@ -247,9 +265,9 @@ function InstallPackage{
247265
# if winget is available, use it to install package
248266
if (Get-Command winget -ErrorAction SilentlyContinue) {
249267
Write-Host "Installing $PackageId with winget"
250-
winget install --id $PackageId -e --source winget
268+
winget install --id $PackageId -e --source winget --silent
251269
$installExitCode = $LASTEXITCODE
252-
Write-Host "'winget install --id $PackageId -e --source winget' exited with code: $($installExitCode)"
270+
Write-Host "'winget install --id $PackageId -e --source winget --silent' exited with code: $($installExitCode)"
253271
if ($installExitCode -eq 0) {
254272
# add package path to path
255273
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") + ";" + $PackagePath
@@ -277,7 +295,7 @@ function InstallPackage{
277295
$tempOutFile = [System.IO.Path]::GetTempFileName() + ".out.json"
278296

279297
$installCommandBlock = {
280-
$installPackageCommand = "Install-WinGetPackage -Scope $($scopeFlagValue) -Source winget -Id $($PackageId) | ConvertTo-Json -Depth 10 | Tee-Object -FilePath '$($tempOutFile)'"
298+
$installPackageCommand = "Install-WinGetPackage -Scope $($scopeFlagValue) -Mode Silent -Source winget -Id $($PackageId) | ConvertTo-Json -Depth 10 | Tee-Object -FilePath '$($tempOutFile)'"
281299
$processCreation = Invoke-CimMethod -ClassName Win32_Process -MethodName Create -Arguments @{CommandLine="C:\Program Files\PowerShell\7\pwsh.exe $($mtaFlag) -Command `"$($installPackageCommand)`""}
282300
if (!($processCreation) -or !($processCreation.ProcessId)) {
283301
Write-Error "Failed to install $PackageId package. Process creation failed."

.configuration/devcenter/tasks/git-clone/runAsUser.ps1

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,36 @@ else {
5353
Write-Host "Microsoft.WinGet.Configuration is already installed"
5454
}
5555

56+
$architecture = "x64"
57+
if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") {
58+
$architecture = "arm64"
59+
}
60+
61+
$msVCLibsPackage = Get-AppxPackage -Name "Microsoft.VCLibs.140.00.UWPDesktop" | Where-Object { $_.Version -ge "14.0.33728.0" }
62+
if (!($msVCLibsPackage)) {
63+
# Install Microsoft.VCLibs.140.00.UWPDesktop
64+
try {
65+
Write-Host "Installing Microsoft.VCLibs.140.00.UWPDesktop"
66+
$MsVCLibs = "$env:TEMP\$([System.IO.Path]::GetRandomFileName())-Microsoft.VCLibs.140.00.UWPDesktop"
67+
$MsVCLibsAppx = "$($MsVCLibs).appx"
68+
69+
Invoke-WebRequest -Uri "https://aka.ms/Microsoft.VCLibs.$($architecture).14.00.Desktop.appx" -OutFile $MsVCLibsAppx
70+
Add-AppxPackage -Path $MsVCLibsAppx -ForceApplicationShutdown
71+
Write-Host "Done Installing Microsoft.VCLibs.140.00.UWPDesktop"
72+
} catch {
73+
Write-Host "Failed to install Microsoft.VCLibs.140.00.UWPDesktop"
74+
Write-Error $_
75+
}
76+
}
77+
5678
$msUiXamlPackage = Get-AppxPackage -Name "Microsoft.UI.Xaml.2.8" | Where-Object { $_.Version -ge "8.2310.30001.0" }
5779
if (!($msUiXamlPackage)) {
5880
# install Microsoft.UI.Xaml
5981
try{
6082
Write-Host "Installing Microsoft.UI.Xaml"
61-
$architecture = "x64"
62-
if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") {
63-
$architecture = "arm64"
64-
}
65-
$MsUiXaml = "$env:TEMP\$([System.IO.Path]::GetRandomFileName())-Microsoft.UI.Xaml.2.8.7"
83+
$MsUiXaml = "$env:TEMP\$([System.IO.Path]::GetRandomFileName())-Microsoft.UI.Xaml.2.8.6"
6684
$MsUiXamlZip = "$($MsUiXaml).zip"
67-
Invoke-WebRequest -Uri "https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.8.7" -OutFile $MsUiXamlZip
85+
Invoke-WebRequest -Uri "https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.8.6" -OutFile $MsUiXamlZip
6886
Expand-Archive $MsUiXamlZip -DestinationPath $MsUiXaml
6987
Add-AppxPackage -Path "$($MsUiXaml)\tools\AppX\$($architecture)\Release\Microsoft.UI.Xaml.2.8.appx" -ForceApplicationShutdown
7088
Write-Host "Done Installing Microsoft.UI.Xaml"
@@ -75,7 +93,7 @@ if (!($msUiXamlPackage)) {
7593
}
7694

7795
$desktopAppInstallerPackage = Get-AppxPackage -Name "Microsoft.DesktopAppInstaller"
78-
if (!($desktopAppInstallerPackage) ) {
96+
if (!($desktopAppInstallerPackage) -or ($desktopAppInstallerPackage.Version -lt "1.22.0.0")) {
7997
# install Microsoft.DesktopAppInstaller
8098
try {
8199
Write-Host "Installing Microsoft.DesktopAppInstaller"

0 commit comments

Comments
 (0)