0
我想在使用msi文件安装之前和之后运行PowerShell脚本。在下面,您可以在Visual Studio 2013中看到我的配置在wix-project中的基本内容。 msi编译时没有错误,我可以运行msi文件,并执行这些步骤直到安装结束而没有错误。Wix Toolset执行Powershell脚本不起作用
在日志中我可以看到CustomAction已经启动,但这不可能是真的,因为应该由底层脚本创建的目录尚未创建。
如果我通过powershell手动运行脚本文件,一切运行良好。所以脚本本身应该工作,不会抛出错误。
有什么建议这里有什么问题?
维克斯项目:
<Product Id="*" Name="MyAPP" Language="1031" Version="1.0.0.0" Manufacturer="Me" UpgradeCode="2A0A9FDB-9DD2-4058-8742-885EF63BFF37">
<!-- 6e8e53ce-66e4-4d97-900c-9678b83e44cc"> -->
<Package InstallerVersion="400" Compressed="yes" InstallScope="perMachine" Languages="1031" Manufacturer="Me" Description="Installiert den MyApp auf ihr System" Comments="NOTHING TO COMMENT"/>
<MediaTemplate EmbedCab="yes" />
<!-- Major Upgrade Rule to disallow downgrades -->
<MajorUpgrade DowngradeErrorMessage="Eine neuere Version vom [ProductName] ist bereits installiert." />
<!-- ################################### -->
<!-- Aktionen vor installation ##########-->
<!-- ################################### -->
<InstallExecuteSequence>
<Custom Action="StartBatchFile" After="InstallInitialize"/>
<Custom Action="EndBatchFile" After="InstallFinalize"/>
</InstallExecuteSequence>
<CustomAction Id="StartBatchFile"
Property="RegisterHttpModulePowerShellProperty"
Value=""C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe" -Version 2.0 -NoProfile -NonInteractive -InputFormat None -ExecutionPolicy Bypass -File "./BeforeInstallationScript.ps1" "[DIR_ComponentRef]""
Execute="immediate" />
<CustomAction Id="EndBatchFile"
Property="RegisterHttpModulePowerShellProperty"
Value=""C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe" o-Versin 2.0 -NoProfile -NonInteractive -InputFormat None -ExecutionPolicy Bypass -File "./AfterInstallationScript.ps1" "[DIR_ComponentRef]""
Execute="immediate" />
<WixVariable Id="WixUIBannerBmp" Value="WixUIBannerBmp.bmp" />
<!-- Background bitmap used on the welcome and completion dialogs 493 × 312 -->
<WixVariable Id="WixUIDialogBmp" Value="WixUIDialogBmp.bmp" />
<!-- ################################### -->
<!-- User-Interface ####################-->
<!-- ################################### -->
<Property Id="WIXUI_INSTALLDIR">DIR_ComponentRef</Property>
<UIRef Id="WixUI_InstallDir" />
<UIRef Id="WixUI_ErrorProgressText" />
<!-- ################################### -->
<!-- Notwendige Abhaengigkeiten ########-->
<!-- ################################### -->
<PropertyRef Id="NETFRAMEWORK40FULL"/>
<Condition Message="Diese Anwendung benoetigt .NET Framework 4.0. Bitte installieren sie zuerst das .NET Framework und starten Sie die Installation erneut.">
<![CDATA[Installed OR NETFRAMEWORK40FULL]]>
</Condition>
<!-- ################################### -->
<!-- FEATURE-Installation ##############-->
<!-- ################################### -->
<Feature Id="FEATURE_MyApp" Title="MyApp" Description="Installiert die Datein des MyApps auf das System" Level="1" AllowAdvertise="no" ConfigurableDirectory="DIR_ComponentRef">
<ComponentRef Id="[...]"/>
[...]
</Feature>
</Product>
<Fragment>
<!-- ################################### -->
<!-- Ordner-Struktur ################### -->
<!-- ################################### -->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="DIR_ComponentRef" Name="MyApp">
<Directory Id="DIR_CONFIGURATION" Name="configuration">
[...]
</Directory>
</Directory>
</Directory>
</Directory>
</Fragment>
<Fragment>
[...]
<!-- ################################### -->
<!-- Componenten-Definition ######## -->
<!-- ################################### -->
<DirectoryRef Id="DIR_ComponentRef">
<Component Id="CMP_MyApp.exe">
<File Id="MyApp.exe" Source="$(var.SourcePath)MyApp.exe" KeyPath="yes" Checksum="yes" />
</Component>
[...]
</DirectoryRef>
</Fragment>
</Wix>
登录-结果:
=== Protokollierung gestartet: 16.11.2016 10:41:12 ===
Aktion 10:41:12: INSTALL.
[...]
Aktion 10:41:35: StartBatchFile.
Aktion gestartet um 10:41:35: StartBatchFile.
Aktion beendet um 10:41:35: StartBatchFile. Rückgabewert 1.
[...]
Aktion beendet um 10:41:38: InstallFinalize. Rückgabewert 1.
Aktion 10:41:38: EndBatchFile.
Aktion gestartet um 10:41:38: EndBatchFile.
Aktion beendet um 10:41:38: EndBatchFile. Rückgabewert 1.
Aktion beendet um 10:41:38: INSTALL. Rückgabewert 1.
[...]
让我知道如果你需要进一步的信息。
这意味着,我需要将ps脚本复制到msi文件所在的同一文件夹中,并且不能直接将它作为资源入站到msi文件中? –
不,您不需要单独将ps1文件复制到目标,ps1脚本在MSI软件包“内部”,将安装在目标上,然后通过th调用e'CustomAction'。 – Moerwald
我正在为此苦苦挣扎。脚本文件现在正确复制到本地系统上的所需位置。但可能为时已晚,因为我在删除系统中的旧安装文件之前需要这些文件。无论如何,我仍然看不到脚本被执行。为什么我能看到?第二次启动安装程序时,来自以前安装执行的文件仍然存在,并且该脚本不会创建该目录,因为我希望由该脚本创建该目录。 –