Add-AppxProvisionedPackage et paramètre positionel
Posté : 26 juin 2025 - 13:19
Version WAPT : 2.6.0.17293
Bonjour,
J'essaie de créer un paquet pour installer la dernière version du client 3CX pour windows. J'ai donc récupéré 3CX.msix et sa dépendance : Microsoft.WindowsAppRuntime.1.7_7000.498.2246.0_x64__8wekyb3d8bbwe.msix que j'ai tout deux ajoutés dans le répertoire du paquet WAPT.
Ensuite j'ai utilisé cette fonction :
Mais lorsque je teste le paquet j'obtiens l'erreur suivante :
Qu'est-ce qui ne va pas dans ma fonction ?
Bonjour,
J'essaie de créer un paquet pour installer la dernière version du client 3CX pour windows. J'ai donc récupéré 3CX.msix et sa dépendance : Microsoft.WindowsAppRuntime.1.7_7000.498.2246.0_x64__8wekyb3d8bbwe.msix que j'ai tout deux ajoutés dans le répertoire du paquet WAPT.
Ensuite j'ai utilisé cette fonction :
Code : Tout sélectionner
appx_package_name = "3CX"
def install():
# Sélection du fichier principal .msix
bin_path_candidates = glob.glob(makepath(f"{appx_package_name}.msix"))
if not bin_path_candidates:
raise Exception(f"Erreur : fichier {appx_package_name}.msix introuvable")
bin_path = bin_path_candidates[0]
# Détection des dépendances éventuelles
dependencies_paths = [
f'"{a}"' for a in glob.glob("*.msix")
if not os.path.basename(a).startswith(appx_package_name)
]
dependencies_pathes_str = ", ".join(dependencies_paths)
# Construction de la commande PowerShell
add_appx_cmd = (
f'Add-AppxProvisionedPackage -Online '
f'-PackagePath "{bin_path}" '
f'-SkipLicense'
)
if dependencies_pathes_str:
add_appx_cmd += f' -DependencyPackagePath {dependencies_pathes_str}'
# Vérification de la version installée de l'appx
appxprovisionedpackage = run_powershell(
f'Get-AppXProvisionedPackage -Online | Where-Object DisplayName -Like "{appx_package_name}"',
output_format="json"
)
current_version = appxprovisionedpackage[0]["Version"] if appxprovisionedpackage else "0.0.0.0"
# Installation si version plus récente ou install forcée
if Version(current_version, 4) < Version(control.get_software_version(), 4) or force:
print(f"Installing: {os.path.basename(bin_path)}")
killalltasks(ensure_list(control.impacted_process))
run_powershell_script(add_appx_cmd.strip(), output_format="text")
else:
print(f"{appx_package_name} is already installed and up-to-date.")
Code : Tout sélectionner
Invoke-Expression : Impossible de trouver un paramètre positionnel acceptant l\'argument «3CX.msix -SkipLicense _x000D__x000A_</S><S S="Error">-DependencyPackagePath Microsoft.WindowsAppRuntime.1.7_7000.498.2246.0_x005F_x64__8wekyb3d8bbwe.msix»._x000D__x000A_</S><S S="Error">Au caractère Ligne:1 : 2_x000D__x000A_</S><S S="Error">+ (invoke-expression -Command "Add-AppxProvisionedPackage -Online -Pack ..._x000D__x000A_</S><S S="Error">