Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix maui desktop scenario runs and make it so that they do not uninst…
…all maui since we prepare the runs in the cloud.
  • Loading branch information
LoopedBard3 committed Jan 24, 2023
commit 45e43356a598a1eed1f41105b0c34b0130025034
4 changes: 1 addition & 3 deletions src/scenarios/mauiblazordesktop/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
post cleanup script
'''

from shared.postcommands import PostCommands, clean_directories
from shared.postcommands import clean_directories

postcommands = PostCommands()
clean_directories()
postcommands.uninstall_workload('maui')
53 changes: 0 additions & 53 deletions src/scenarios/mauiblazordesktop/pre.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,62 +15,9 @@

setup_loggers(True)
NugetURL = 'https://raw.githubusercontent.com/dotnet/maui/net6.0/NuGet.config'
WebViewURL = 'https://go.microsoft.com/fwlink/p/?LinkId=2124703' # Obtained from https://developer.microsoft.com/en-us/microsoft-edge/webview2/#download-section
WebViewInstalled = False
NugetFile = requests.get(NugetURL)
open('./Nuget.config', 'wb').write(NugetFile.content)

lmkey = r"SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}"
cukey = r"Software\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}"
with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as hklm_hive:
try:
with winreg.OpenKey(hklm_hive, lmkey) as openkey:
pvvalue = winreg.QueryValueEx(openkey, 'pv')[0]
if pvvalue and pvvalue != '' and pvvalue != '0.0.0.0':
WebViewInstalled = True
getLogger().info(f"WebView Found; pvvalue(version) {pvvalue}")
except:
getLogger().warning("WebView not verified in Local_Machine Registry")
if not WebViewInstalled:
try:
with winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER) as hkcu_hive:
with winreg.OpenKey(hkcu_hive, cukey) as openkey:
pvvalue = winreg.QueryValueEx(openkey, 'pv')[0]
if pvvalue and pvvalue != '' and pvvalue != '0.0.0.0':
WebViewInstalled = True
getLogger().info(f"WebView Found; pvvalue(version) {pvvalue}")
except:
getLogger().warning("WebView not verified in Current_Machine Registry")
if not WebViewInstalled:
getLogger().info("Installing WebView2")
WebViewInstallFile = requests.get(WebViewURL)
open('./MicrosoftEdgeWebview2Setup.exe', 'wb').write(WebViewInstallFile.content)
subprocess.run(['powershell', '-Command', r'Start-Process "./MicrosoftEdgeWebview2Setup.exe" -Wait'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as hklm_hive:
try:
with winreg.OpenKey(hklm_hive, lmkey) as openkey:
pvvalue = winreg.QueryValueEx(openkey, 'pv')[0]
if pvvalue and pvvalue != '' and pvvalue != '0.0.0.0':
WebViewInstalled = True
getLogger().info(f"WebView Found; pvvalue(version) {pvvalue}")
except:
getLogger().warning("WebView not verified in Local_Machine Registry")
if not WebViewInstalled:
try:
with winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER) as hkcu_hive:
with winreg.OpenKey(hkcu_hive, cukey) as openkey:
pvvalue = winreg.QueryValueEx(openkey, 'pv')[0]
if pvvalue and pvvalue != '' and pvvalue != '0.0.0.0':
WebViewInstalled = True
getLogger().info(f"WebView Found; pvvalue(version) {pvvalue}")
except:
getLogger().warning("WebView not verified in Current_Machine Registry.")
getLogger().error("Blazor cannot run without WebView installed, exiting execution.")
sys.exit(-1)
else:
getLogger().info("WebViewAlreadyInstalled")


precommands = PreCommands()
precommands.install_workload('maui', ['--from-rollback-file', 'https://aka.ms/dotnet/maui/net6.0.json', '--configfile', './Nuget.config'])
precommands.new(template='maui-blazor',
Expand Down
56 changes: 56 additions & 0 deletions src/scenarios/mauiblazordesktop/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
EXENAME = 'MauiBlazorDesktopTesting'

def main():
setup_loggers(True)
install_webview()
traits = TestTraits(exename=EXENAME,
guiapp='true',
startupmetric='WinUIBlazor',
Expand All @@ -16,6 +18,60 @@ def main():
runner = Runner(traits)
runner.run()

def install_webview():
WebViewURL = 'https://go.microsoft.com/fwlink/p/?LinkId=2124703' # Obtained from https://developer.microsoft.com/en-us/microsoft-edge/webview2/#download-section
WebViewInstalled = False
lmkey = r"SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}"
cukey = r"Software\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}"
with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as hklm_hive:
try:
with winreg.OpenKey(hklm_hive, lmkey) as openkey:
pvvalue = winreg.QueryValueEx(openkey, 'pv')[0]
if pvvalue and pvvalue != '' and pvvalue != '0.0.0.0':
WebViewInstalled = True
getLogger().info(f"WebView Found; pvvalue(version) {pvvalue}")
except:
getLogger().warning("WebView not verified in Local_Machine Registry")
if not WebViewInstalled:
try:
with winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER) as hkcu_hive:
with winreg.OpenKey(hkcu_hive, cukey) as openkey:
pvvalue = winreg.QueryValueEx(openkey, 'pv')[0]
if pvvalue and pvvalue != '' and pvvalue != '0.0.0.0':
WebViewInstalled = True
getLogger().info(f"WebView Found; pvvalue(version) {pvvalue}")
except:
getLogger().warning("WebView not verified in Current_Machine Registry")
if not WebViewInstalled:
getLogger().info("Installing WebView2")
WebViewInstallFile = requests.get(WebViewURL)
open('./MicrosoftEdgeWebview2Setup.exe', 'wb').write(WebViewInstallFile.content)
subprocess.run(['powershell', '-Command', r'Start-Process "./MicrosoftEdgeWebview2Setup.exe" -Wait'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as hklm_hive:
try:
with winreg.OpenKey(hklm_hive, lmkey) as openkey:
pvvalue = winreg.QueryValueEx(openkey, 'pv')[0]
if pvvalue and pvvalue != '' and pvvalue != '0.0.0.0':
WebViewInstalled = True
getLogger().info(f"WebView Found; pvvalue(version) {pvvalue}")
except:
getLogger().warning("WebView not verified in Local_Machine Registry")
if not WebViewInstalled:
try:
with winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER) as hkcu_hive:
with winreg.OpenKey(hkcu_hive, cukey) as openkey:
pvvalue = winreg.QueryValueEx(openkey, 'pv')[0]
if pvvalue and pvvalue != '' and pvvalue != '0.0.0.0':
WebViewInstalled = True
getLogger().info(f"WebView Found; pvvalue(version) {pvvalue}")
except:
getLogger().warning("WebView not verified in Current_Machine Registry.")
getLogger().error("Blazor cannot run without WebView installed, exiting execution.")
sys.exit(-1)
else:
getLogger().info("WebViewAlreadyInstalled")



if __name__ == "__main__":
result = subprocess.run(['powershell', '-Command', r'Get-ChildItem .\pub\Microsoft.Maui.dll | Select-Object -ExpandProperty VersionInfo | Select-Object ProductVersion | Select-Object -ExpandProperty ProductVersion'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
Expand Down
4 changes: 1 addition & 3 deletions src/scenarios/mauidesktop/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
post cleanup script
'''

from shared.postcommands import PostCommands, clean_directories
from shared.postcommands import clean_directories

postcommands = PostCommands()
clean_directories()
postcommands.uninstall_workload('maui')