Skip to content

Commit a727895

Browse files
committed
Verified that running powershell is possible, just needed to set shell in subprocess.run to false. Trying to extract the data we want now.
1 parent c524269 commit a727895

3 files changed

Lines changed: 15 additions & 11 deletions

File tree

src/scenarios/mauiblazorios/pre.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from shared import const
88
from shared.mauisharedpython import remove_aab_files, install_versioned_maui
99
from shared.precommands import PreCommands
10-
from shared.versionmanager import versions_write_json, get_version_from_dll_powershell
10+
from shared.versionmanager import versions_write_json, get_version_from_dll_powershell_ios
1111
from test import EXENAME
1212

1313
setup_loggers(True)
@@ -72,8 +72,8 @@
7272
remove_aab_files(output_dir)
7373

7474
# Copy the MauiVersion to a file so we have it on the machine
75-
# maui_version = get_version_from_dll_powershell(rf".\{const.APPDIR}\obj\Release\{precommands.framework}\android-arm64\linked\Microsoft.Maui.dll")
76-
# version_dict = { "mauiVersion": maui_version }
77-
# versions_write_json(version_dict, rf"{output_dir}\versions.json")
78-
# print(f"Versions: {version_dict}")
75+
maui_version = get_version_from_dll_powershell_ios(rf"./{const.APPDIR}/obj/Release/{precommands.framework}/ios-arm64/ipa/Payload/{EXENAME}.app/Microsoft.Maui.dll") # TODO: Figure out another way to get the Maui Version
76+
version_dict = { "mauiVersion": maui_version }
77+
versions_write_json(version_dict, rf"{output_dir}\versions.json")
78+
print(f"Versions: {version_dict} from location " + rf"./{const.APPDIR}/obj/Release/{precommands.framework}/ios-arm64/ipa/Payload/{EXENAME}.app/Microsoft.Maui.dll")
7979

src/scenarios/mauiios/pre.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from shared import const
99
from shared.mauisharedpython import remove_aab_files, install_versioned_maui
1010
from shared.precommands import PreCommands
11-
from shared.versionmanager import versions_write_json, get_version_from_dll_powershell
11+
from shared.versionmanager import versions_write_json, get_version_from_dll_powershell_ios
1212
from test import EXENAME
1313

1414
setup_loggers(True)
@@ -38,7 +38,7 @@
3838
print(result.stdout.decode('utf-8').strip())
3939

4040
# Copy the MauiVersion to a file so we have it on the machine
41-
#maui_version = get_version_from_dll_powershell(rf".\{const.APPDIR}\obj\Release\{precommands.framework}\android-arm64\linked\Microsoft.Maui.dll") # TODO: Figure out another way to get the Maui Version
42-
#version_dict = { "mauiVersion": maui_version }
43-
#versions_write_json(version_dict, rf"{output_dir}\versions.json")
44-
#print(f"Versions: {version_dict}")
41+
maui_version = get_version_from_dll_powershell_ios(rf"./{const.APPDIR}/obj/Release/{precommands.framework}/ios-arm64/ipa/Payload/{EXENAME}.app/Microsoft.Maui.dll") # TODO: Figure out another way to get the Maui Version
42+
version_dict = { "mauiVersion": maui_version }
43+
versions_write_json(version_dict, rf"{output_dir}\versions.json")
44+
print(f"Versions: {version_dict} from location " + rf"./{const.APPDIR}/obj/Release/{precommands.framework}/ios-arm64/ipa/Payload/{EXENAME}.app/Microsoft.Maui.dll")

src/scenarios/shared/versionmanager.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,9 @@ def versions_read_json_file_save_env(inputfile = 'versions.json'):
2727
os.remove(inputfile)
2828

2929
def get_version_from_dll_powershell(dll_path: str):
30-
result = subprocess.run(['powershell.sh', '-Command', rf'Get-ChildItem {dll_path} | Select-Object -ExpandProperty VersionInfo | Select-Object -ExpandProperty ProductVersion'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
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)
3131
return result.stdout.decode('utf-8').strip()
32+
33+
def get_version_from_dll_powershell_ios(dll_path: str):
34+
result = subprocess.run(['pwsh', '-Command', rf'Get-ChildItem {dll_path} | Select-Object -ExpandProperty VersionInfo | Select-Object -ExpandProperty ProductVersion'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False)
35+
return result.stdout.decode('utf-8').strip()

0 commit comments

Comments
 (0)