Enable VirtualPlatform

This commit is contained in:
LoveSy 2021-12-12 08:47:30 +08:00
parent 9da5349c42
commit 46f1df7fe8

View File

@ -53,8 +53,6 @@ jobs:
out_file = "xaml.appx" out_file = "xaml.appx"
if not os.path.isfile(out_file): if not os.path.isfile(out_file):
urllib.request.urlretrieve(link, out_file) urllib.request.urlretrieve(link, out_file)
with open(os.environ['GITHUB_ENV'], 'a') as f:
f.write(f'XAML_NAME={a.string.split("_", 1)[0]}\n')
a = html.find("a", string=re.compile(f"Microsoft\.VCLibs\..*_{arch}_.*\.appx")) a = html.find("a", string=re.compile(f"Microsoft\.VCLibs\..*_{arch}_.*\.appx"))
link = a["href"] link = a["href"]
@ -62,8 +60,6 @@ jobs:
out_file = "vclibs.appx" out_file = "vclibs.appx"
if not os.path.isfile(out_file): if not os.path.isfile(out_file):
urllib.request.urlretrieve(link, out_file) urllib.request.urlretrieve(link, out_file)
with open(os.environ['GITHUB_ENV'], 'a') as f:
f.write(f'VCLIB_NAME={a.string.split("_", 1)[0]}\n')
a = html.find("a", string=re.compile("MicrosoftCorporationII\.WindowsSubsystemForAndroid_.*\.msixbundle")) a = html.find("a", string=re.compile("MicrosoftCorporationII\.WindowsSubsystemForAndroid_.*\.msixbundle"))
link = a["href"] link = a["href"]
@ -435,6 +431,7 @@ jobs:
\$proc = Start-Process -PassThru -WindowStyle Hidden -Verb RunAs powershell.exe -Args "-executionpolicy bypass -command Set-Location \`"\$PSScriptRoot\`"; \`"\$PSCommandPath\`" EVAL" \$proc = Start-Process -PassThru -WindowStyle Hidden -Verb RunAs powershell.exe -Args "-executionpolicy bypass -command Set-Location \`"\$PSScriptRoot\`"; \`"\$PSCommandPath\`" EVAL"
\$proc.WaitForExit() \$proc.WaitForExit()
if (\$proc.ExitCode -ne 0) { if (\$proc.ExitCode -ne 0) {
Clear-Host
Write-Warning "Failed to launch start as Administrator\`r\`nPress any key to exit" Write-Warning "Failed to launch start as Administrator\`r\`nPress any key to exit"
\$null = \$Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown'); \$null = \$Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
} }
@ -447,25 +444,29 @@ jobs:
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1" reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"
\$Installed = \$null \$VMP = Get-WindowsOptionalFeature -Online -FeatureName 'VirtualMachinePlatform'
\$Installed = Get-AppxPackage -Name '$XAML_NAME' if (\$VMP.State -ne "Enabled") {
Enable-WindowsOptionalFeature -Online -NoRestart -FeatureName 'VirtualMachinePlatform'
If (\$null -eq \$Installed) { Clear-Host
Add-AppxPackage -Path xaml.appx Write-Warning "Need restart to enable virtual machine platform\`r\`nPress y to restart or press any key to exit"
\$key = \$Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
If ("y" -eq \$key.Character) {
Restart-Computer -Confirm
}
Else {
exit 1
}
} }
\$Installed = \$null Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Path vclibs.appx
\$Installed = Get-AppxPackage -Name '$VCLIB_NAME' Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Path xaml.appx
If (\$null -eq \$Installed) {
Add-AppxPackage -Path vclibs.appx
}
\$Installed = \$null \$Installed = \$null
\$Installed = Get-AppxPackage -Name 'MicrosoftCorporationII.WindowsSubsystemForAndroid' \$Installed = Get-AppxPackage -Name 'MicrosoftCorporationII.WindowsSubsystemForAndroid'
If (\$null -ne \$Installed) { If (\$null -ne \$Installed) {
If (-not (\$Installed.IsDevelopmentMode)) { If (-not (\$Installed.IsDevelopmentMode)) {
Clear-Host
Write-Warning "There is already one installed WSA. Please uninstall it first.\`r\`nPress y to uninstall existing WSA or press any key to exit" Write-Warning "There is already one installed WSA. Please uninstall it first.\`r\`nPress y to uninstall existing WSA or press any key to exit"
\$key = \$Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') \$key = \$Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
If ("y" -eq \$key.Character) { If ("y" -eq \$key.Character) {
@ -476,13 +477,15 @@ jobs:
} }
} }
Else { Else {
Clear-Host
Write-Host "Uninstalling existing installation while preserving userdata..." Write-Host "Uninstalling existing installation while preserving userdata..."
Remove-AppxPackage -PreserveApplicationData -Package \$Installed.PackageFullName Remove-AppxPackage -PreserveApplicationData -Package \$Installed.PackageFullName
} }
} }
Clear-Host
Write-Host "Installing MagiskOnWSA..." Write-Host "Installing MagiskOnWSA..."
Add-AppxPackage -Register .\AppxManifest.xml Add-AppxPackage -Register .\AppxManifest.xml
Clear-Host
EOF EOF
- name: Generate artifact name - name: Generate artifact name
run: | run: |