Skip to content

Commit b13d06a

Browse files
committed
Move GetVersionFromDLL to the version manager shared script since it can be used to get values from any Dll on systems with powershell support.
1 parent aecc325 commit b13d06a

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

src/scenarios/mauiandroid/pre.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
'''
44
import sys
55
import requests
6-
from mauishared.mauisharedpython import RemoveAABFiles, GetVersionFromDll
6+
from mauishared.mauisharedpython import RemoveAABFiles
77
from performance.logger import setup_loggers, getLogger
88
from shared import const
99
from shared.precommands import PreCommands
10-
from shared.versionmanager import versionswritejson
10+
from shared.versionmanager import versionswritejson, GetVersionFromDllPowershell
1111
from test import EXENAME
1212

1313
setup_loggers(True)
@@ -35,7 +35,7 @@
3535
RemoveAABFiles(precommands.output)
3636

3737
# Copy the MauiVersion to a file so we have it on the machine
38-
maui_version = GetVersionFromDll(rf".\{const.APPDIR}\obj\Release\{precommands.framework}\{precommands.runtime_identifier}\linked\Microsoft.Maui.dll")
38+
maui_version = GetVersionFromDllPowershell(rf".\{const.APPDIR}\obj\Release\{precommands.framework}\{precommands.runtime_identifier}\linked\Microsoft.Maui.dll")
3939
version_dict = { "mauiVersion": maui_version }
4040
versionswritejson(version_dict, rf"{precommands.output}\versions.json")
4141
print(f"Versions: {version_dict}")

src/scenarios/mauiandroidpodcast/pre.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
'''
44
import requests
55
import subprocess
6-
from mauishared.mauisharedpython import RemoveAABFiles, GetVersionFromDll
6+
from mauishared.mauisharedpython import RemoveAABFiles
77
from performance.logger import setup_loggers, getLogger
88
from shared.precommands import PreCommands
9-
from shared.versionmanager import versionswritejson
9+
from shared.versionmanager import versionswritejson, GetVersionFromDllPowershell
1010
from shared import const
1111

1212
setup_loggers(True)
@@ -29,7 +29,7 @@
2929
# Remove the aab files as we don't need them, this saves space
3030
RemoveAABFiles(precommands.output)
3131

32-
maui_version = GetVersionFromDll(f".\{const.APPDIR}\src\Mobile\obj\Release\{precommands.framework}\{precommands.runtime_identifier}\linked\Microsoft.Maui.dll")
32+
maui_version = GetVersionFromDllPowershell(f".\{const.APPDIR}\src\Mobile\obj\Release\{precommands.framework}\{precommands.runtime_identifier}\linked\Microsoft.Maui.dll")
3333
version_dict = { "mauiVersion": maui_version }
3434
versionswritejson(version_dict, rf"{precommands.output}\versions.json")
3535
print(f"Versions: {version_dict}")

src/scenarios/mauiblazorandroid/pre.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
'''
44
import sys
55
import requests
6-
from mauishared.mauisharedpython import RemoveAABFiles, GetVersionFromDll
6+
from mauishared.mauisharedpython import RemoveAABFiles
77
from performance.logger import setup_loggers, getLogger
88
from shared import const
99
from shared.precommands import PreCommands
10-
from shared.versionmanager import versionswritejson
10+
from shared.versionmanager import versionswritejson, GetVersionFromDllPowershell
1111
from test import EXENAME
1212

1313
setup_loggers(True)
@@ -72,7 +72,7 @@
7272
RemoveAABFiles(precommands.output)
7373

7474
# Copy the MauiVersion to a file so we have it on the machine
75-
maui_version = GetVersionFromDll(rf".\{const.APPDIR}\obj\Release\{precommands.framework}\{precommands.runtime_identifier}\linked\Microsoft.Maui.dll")
75+
maui_version = GetVersionFromDllPowershell(rf".\{const.APPDIR}\obj\Release\{precommands.framework}\{precommands.runtime_identifier}\linked\Microsoft.Maui.dll")
7676
version_dict = { "mauiVersion": maui_version }
7777
versionswritejson(version_dict, rf"{precommands.output}\versions.json")
7878
print(f"Versions: {version_dict}")

src/scenarios/mauishared/mauisharedpython.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,3 @@ def RemoveAABFiles(output_dir="."):
77
for file in file_list:
88
if file.endswith(".aab"):
99
os.remove(os.path.join(output_dir, file))
10-
11-
def GetVersionFromDll(dll_path: str):
12-
result = subprocess.run(['powershell', '-Command', rf'Get-ChildItem {dll_path} | Select-Object -ExpandProperty VersionInfo | Select-Object -ExpandProperty ProductVersion'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
13-
return result.stdout.decode('utf-8').strip()

src/scenarios/shared/versionmanager.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
'''
44
import json
55
import os
6+
import subprocess
67

78
def versionswritejson(versiondict: dict, outputfile = 'versions.json'):
89
with open(outputfile, 'w') as file:
@@ -23,4 +24,8 @@ def versionsreadjsonfilesaveenv(inputfile = 'versions.json'):
2324

2425
# Remove the versions.json file if we are in the lab to ensure SOD doesn't pick it up
2526
if "PERFLAB_INLAB" in os.environ and os.environ["PERFLAB_INLAB"] == "1":
26-
os.remove(inputfile)
27+
os.remove(inputfile)
28+
29+
def GetVersionFromDllPowershell(dll_path: str):
30+
result = subprocess.run(['powershell', '-Command', rf'Get-ChildItem {dll_path} | Select-Object -ExpandProperty VersionInfo | Select-Object -ExpandProperty ProductVersion'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
31+
return result.stdout.decode('utf-8').strip()

0 commit comments

Comments
 (0)