Skip to content

Commit 45e4335

Browse files
committed
Fix maui desktop scenario runs and make it so that they do not uninstall maui since we prepare the runs in the cloud.
1 parent 0ad00dc commit 45e4335

File tree

4 files changed

+58
-59
lines changed

4 files changed

+58
-59
lines changed

src/scenarios/mauiblazordesktop/post.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
post cleanup script
33
'''
44

5-
from shared.postcommands import PostCommands, clean_directories
5+
from shared.postcommands import clean_directories
66

7-
postcommands = PostCommands()
87
clean_directories()
9-
postcommands.uninstall_workload('maui')

src/scenarios/mauiblazordesktop/pre.py

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -15,62 +15,9 @@
1515

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

23-
lmkey = r"SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}"
24-
cukey = r"Software\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}"
25-
with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as hklm_hive:
26-
try:
27-
with winreg.OpenKey(hklm_hive, lmkey) as openkey:
28-
pvvalue = winreg.QueryValueEx(openkey, 'pv')[0]
29-
if pvvalue and pvvalue != '' and pvvalue != '0.0.0.0':
30-
WebViewInstalled = True
31-
getLogger().info(f"WebView Found; pvvalue(version) {pvvalue}")
32-
except:
33-
getLogger().warning("WebView not verified in Local_Machine Registry")
34-
if not WebViewInstalled:
35-
try:
36-
with winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER) as hkcu_hive:
37-
with winreg.OpenKey(hkcu_hive, cukey) as openkey:
38-
pvvalue = winreg.QueryValueEx(openkey, 'pv')[0]
39-
if pvvalue and pvvalue != '' and pvvalue != '0.0.0.0':
40-
WebViewInstalled = True
41-
getLogger().info(f"WebView Found; pvvalue(version) {pvvalue}")
42-
except:
43-
getLogger().warning("WebView not verified in Current_Machine Registry")
44-
if not WebViewInstalled:
45-
getLogger().info("Installing WebView2")
46-
WebViewInstallFile = requests.get(WebViewURL)
47-
open('./MicrosoftEdgeWebview2Setup.exe', 'wb').write(WebViewInstallFile.content)
48-
subprocess.run(['powershell', '-Command', r'Start-Process "./MicrosoftEdgeWebview2Setup.exe" -Wait'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
49-
with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as hklm_hive:
50-
try:
51-
with winreg.OpenKey(hklm_hive, lmkey) as openkey:
52-
pvvalue = winreg.QueryValueEx(openkey, 'pv')[0]
53-
if pvvalue and pvvalue != '' and pvvalue != '0.0.0.0':
54-
WebViewInstalled = True
55-
getLogger().info(f"WebView Found; pvvalue(version) {pvvalue}")
56-
except:
57-
getLogger().warning("WebView not verified in Local_Machine Registry")
58-
if not WebViewInstalled:
59-
try:
60-
with winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER) as hkcu_hive:
61-
with winreg.OpenKey(hkcu_hive, cukey) as openkey:
62-
pvvalue = winreg.QueryValueEx(openkey, 'pv')[0]
63-
if pvvalue and pvvalue != '' and pvvalue != '0.0.0.0':
64-
WebViewInstalled = True
65-
getLogger().info(f"WebView Found; pvvalue(version) {pvvalue}")
66-
except:
67-
getLogger().warning("WebView not verified in Current_Machine Registry.")
68-
getLogger().error("Blazor cannot run without WebView installed, exiting execution.")
69-
sys.exit(-1)
70-
else:
71-
getLogger().info("WebViewAlreadyInstalled")
72-
73-
7421
precommands = PreCommands()
7522
precommands.install_workload('maui', ['--from-rollback-file', 'https://aka.ms/dotnet/maui/net6.0.json', '--configfile', './Nuget.config'])
7623
precommands.new(template='maui-blazor',

src/scenarios/mauiblazordesktop/test.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
EXENAME = 'MauiBlazorDesktopTesting'
66

77
def main():
8+
setup_loggers(True)
9+
install_webview()
810
traits = TestTraits(exename=EXENAME,
911
guiapp='true',
1012
startupmetric='WinUIBlazor',
@@ -16,6 +18,60 @@ def main():
1618
runner = Runner(traits)
1719
runner.run()
1820

21+
def install_webview():
22+
WebViewURL = 'https://go.microsoft.com/fwlink/p/?LinkId=2124703' # Obtained from https://developer.microsoft.com/en-us/microsoft-edge/webview2/#download-section
23+
WebViewInstalled = False
24+
lmkey = r"SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}"
25+
cukey = r"Software\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}"
26+
with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as hklm_hive:
27+
try:
28+
with winreg.OpenKey(hklm_hive, lmkey) as openkey:
29+
pvvalue = winreg.QueryValueEx(openkey, 'pv')[0]
30+
if pvvalue and pvvalue != '' and pvvalue != '0.0.0.0':
31+
WebViewInstalled = True
32+
getLogger().info(f"WebView Found; pvvalue(version) {pvvalue}")
33+
except:
34+
getLogger().warning("WebView not verified in Local_Machine Registry")
35+
if not WebViewInstalled:
36+
try:
37+
with winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER) as hkcu_hive:
38+
with winreg.OpenKey(hkcu_hive, cukey) as openkey:
39+
pvvalue = winreg.QueryValueEx(openkey, 'pv')[0]
40+
if pvvalue and pvvalue != '' and pvvalue != '0.0.0.0':
41+
WebViewInstalled = True
42+
getLogger().info(f"WebView Found; pvvalue(version) {pvvalue}")
43+
except:
44+
getLogger().warning("WebView not verified in Current_Machine Registry")
45+
if not WebViewInstalled:
46+
getLogger().info("Installing WebView2")
47+
WebViewInstallFile = requests.get(WebViewURL)
48+
open('./MicrosoftEdgeWebview2Setup.exe', 'wb').write(WebViewInstallFile.content)
49+
subprocess.run(['powershell', '-Command', r'Start-Process "./MicrosoftEdgeWebview2Setup.exe" -Wait'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
50+
with winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE) as hklm_hive:
51+
try:
52+
with winreg.OpenKey(hklm_hive, lmkey) as openkey:
53+
pvvalue = winreg.QueryValueEx(openkey, 'pv')[0]
54+
if pvvalue and pvvalue != '' and pvvalue != '0.0.0.0':
55+
WebViewInstalled = True
56+
getLogger().info(f"WebView Found; pvvalue(version) {pvvalue}")
57+
except:
58+
getLogger().warning("WebView not verified in Local_Machine Registry")
59+
if not WebViewInstalled:
60+
try:
61+
with winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER) as hkcu_hive:
62+
with winreg.OpenKey(hkcu_hive, cukey) as openkey:
63+
pvvalue = winreg.QueryValueEx(openkey, 'pv')[0]
64+
if pvvalue and pvvalue != '' and pvvalue != '0.0.0.0':
65+
WebViewInstalled = True
66+
getLogger().info(f"WebView Found; pvvalue(version) {pvvalue}")
67+
except:
68+
getLogger().warning("WebView not verified in Current_Machine Registry.")
69+
getLogger().error("Blazor cannot run without WebView installed, exiting execution.")
70+
sys.exit(-1)
71+
else:
72+
getLogger().info("WebViewAlreadyInstalled")
73+
74+
1975

2076
if __name__ == "__main__":
2177
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)

src/scenarios/mauidesktop/post.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
post cleanup script
33
'''
44

5-
from shared.postcommands import PostCommands, clean_directories
5+
from shared.postcommands import clean_directories
66

7-
postcommands = PostCommands()
87
clean_directories()
9-
postcommands.uninstall_workload('maui')

0 commit comments

Comments
 (0)