gpt4 book ai didi

wix - 我鄙视WIX,我要WIX死(真题: can't run custom action and delete a folder at the same time)

转载 作者:行者123 更新时间:2023-12-04 07:01:43 28 4
gpt4 key购买 nike

所以我陷入了蜡 hell 。过来指点笑我。

我正在尝试创建一个 wix 安装程序,该安装程序可以执行一些中等复杂的事情,并在卸载时自行清理。这显然是太大的希望,因为...

我可以选择执行我的清理自定义操作或删除安装文件夹,但不能同时选择两者。

安装程序有五个自定义操作——两个将 SSL 证书绑定(bind)到端口并为该端口添加 url ACL,两个删除这些,一个在安装后运行应用程序。

如果我不执行删除证书绑定(bind)和 url ACL 的两个自定义操作(通过删除它们或者即使它们失败),那么安装文件夹 按预期删除。 如果我确实执行了两个自定义绑定(bind),则不会删除安装文件夹。 因为我在蜡笔 hell 。

自定义操作非常简单。看,他们来了。

<CustomAction Id="LaunchApplication"
BinaryKey="WixCA"
DllEntry="WixShellExec"
Impersonate="yes" />
<CustomAction Id="AddHttpsReservation"
Directory="INSTALLFOLDER"
ExeCommand="[SystemFolder]netsh http add urlacl url=https://127.0.0.1:9001/ sddl=D:(A;;GX;;;BU)"
Execute="deferred"
Impersonate="no"
Return="asyncWait" />
<CustomAction Id="AddHttpsBinding"
Directory="INSTALLFOLDER"
ExeCommand="[SystemFolder]netsh http add sslcert ipport=0.0.0.0:9001 certhash=S0M3C3RTHA5H appid={8feef448-1a4f-408f-b6d4-8a90300517ed}"
Execute="deferred"
Impersonate="no"
Return="asyncWait" />
<CustomAction Id="DeleteHttpsReservation"
Directory="INSTALLFOLDER"
ExeCommand="[SystemFolder]netsh http delete urlacl url=https://127.0.0.1:9001/"
Execute="deferred"
Impersonate="no"
Return="asyncWait" />
<CustomAction Id="DeleteHttpsBinding"
Directory="INSTALLFOLDER"
ExeCommand="[SystemFolder]netsh http delete sslcert ipport=0.0.0.0:9001"
Execute="deferred"
Impersonate="no"
Return="asyncWait" />

这是我的执行顺序。对于有经验的人来说,它可能看起来有点奇怪;我绝对没有使用 wix 的经验(我只构建和维护了八个左右相对复杂的安装程序,如果我们谈论 C# 应用程序,这将使我成为一名企业架构师,但因为这些是 wix 安装程序,我仍然被认为是n 度的白痴),但是这些( 几乎 )给了我我想要的 cargo ,所以这就是为什么竹飞机:
<InstallExecuteSequence>
<Custom Action="LaunchApplication"
After="InstallFinalize">NOT REMOVE~="ALL"</Custom>
<Custom Action="AddHttpsBinding"
Before="InstallFinalize">Not Installed</Custom>
<Custom Action="AddHttpsReservation"
Before="InstallFinalize">Not Installed</Custom>
<Custom Action="DeleteHttpsReservation"
After="InstallInitialize">REMOVE~="ALL"</Custom>
<Custom Action="DeleteHttpsBinding"
After="InstallInitialize">REMOVE~="ALL"</Custom>
</InstallExecuteSequence>

(旁注,如果我尝试删除 Before="InstallFinalize"或任何其他随机位置,我已经尝试过该死的事情失败并出现错误代码 1631,我认为这是一个海拔问题,但谁知道,因为 wix hell )

同样,如果我注释掉最后两个,安装文件夹会在卸载时被删除,就像我想要的那样(就像微软想要的那样,如果你试图让你的应用程序获得认证,它会提示)。如果我尝试选择另一个 install execute sequence对于调度,自定义操作失败(前面提到过 1631)但目录被删除。我已经尝试了一些随机的和一些合乎逻辑的(比如 RemoveFolders,如果它有效,那不是很好)。

成功执行删除操作(以及有关 wix hell)的某些内容会阻止该目录被删除!

如果我不注释掉最后两行,除了安装文件夹之外的所有内容都会被卸载,这会在日志中引发错误,就像在这里看到它一样(轻微的语言警告):

MSI (s) (0C:C0) [13:25:59:184]: Executing op: FileRemove(,FileName=readme.txt,,ComponentId={F3E98E05-E32A-5DC0-A551-64807B816AC2})
MSI (s) (0C:C0) [13:25:59:185]: Verifying accessibility of file: readme.txt
MSI (s) (0C:C0) [13:25:59:187]: Note: 1: 2318 2:
MSI (s) (0C:C0) [13:25:59:187]: Note: 1: 2327 2: 32 3: C:\Program Files (x86)\DealingWithThisWixBullshitInstaller\
MSI (s) (0C:C0) [13:25:59:188]: Note: 1: 2205 2: 3: Error
MSI (s) (0C:C0) [13:25:59:188]: Note: 1: 2228 2: 3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 2911
DEBUG: Error 2911: Could not remove the folder C:\Program Files (x86)\DealingWithThisWixBullshitInstaller\.
MSI (s) (0C:C0) [13:25:59:190]: Note: 1: 2318 2:
MSI (s) (0C:C0) [13:25:59:191]: Note: 1: 2327 2: 32 3: C:\Program Files (x86)\DealingWithThisWixBullshitInstaller\
MSI (s) (0C:C0) [13:25:59:191]: Note: 1: 2205 2: 3: Error
MSI (s) (0C:C0) [13:25:59:191]: Note: 1: 2228 2: 3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 2911
The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2911. The arguments are: C:\Program Files (x86)\DealingWithThisWixBullshitInstaller\, ,
DEBUG: Error 2911: Could not remove the folder C:\Program Files (x86)\DealingWithThisWixBullshitInstaller\.

我一直在 build 的竹子飞机都没有带来华丽的丰富 cargo ,也没有干净的卸载。我不知所措。有任何想法吗?

对于那里的完成者,这是我的 MCVE 中的整个 wxs(再次,轻微的语言警告):

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension">
<Product Id="*"
Name="DealingWithThisWixBullshitInstaller"
Language="1033"
Version="1.0.0.0"
Manufacturer="Derp"
UpgradeCode="1408102b-2ffd-41ff-ad57-6319b7fbfa58">
<Package InstallerVersion="200"
Compressed="yes"
InstallScope="perMachine"
InstallPrivileges="elevated" />

<MajorUpgrade DowngradeErrorMessage="A newer version of this product is already installed." />
<MediaTemplate />

<Feature Id="ProductFeature"
Title="DealingWithThisWixBullshitInstaller"
Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>

<Property Id="WixShellExecTarget"
Value="[#DealingWithThisWixBullshitExecutable]" />

<CustomAction Id="LaunchApplication"
BinaryKey="WixCA"
DllEntry="WixShellExec"
Impersonate="yes" />
<CustomAction Id="AddHttpsReservation"
Directory="INSTALLFOLDER"
ExeCommand="[SystemFolder]netsh http add urlacl url=https://127.0.0.1:9998/ sddl=D:(A;;GX;;;BU)"
Execute="deferred"
Impersonate="no"
Return="asyncWait" />
<CustomAction Id="AddHttpsBinding"
Directory="INSTALLFOLDER"
ExeCommand="[SystemFolder]netsh http add sslcert ipport=0.0.0.0:9998 certhash=E68AA1985440FDAD0BB07547BE2C9957F416709B appid={8feef448-1a4f-408f-b6d4-8a90300517ed}"
Execute="deferred"
Impersonate="no"
Return="asyncWait" />
<CustomAction Id="DeleteHttpsReservation"
Directory="INSTALLFOLDER"
ExeCommand="[SystemFolder]netsh http delete urlacl url=https://127.0.0.1:9998/"
Execute="deferred"
Impersonate="no"
Return="asyncWait" />
<CustomAction Id="DeleteHttpsBinding"
Directory="INSTALLFOLDER"
ExeCommand="[SystemFolder]netsh http delete sslcert ipport=0.0.0.0:9998"
Execute="deferred"
Impersonate="no"
Return="asyncWait" />

<InstallExecuteSequence>
<Custom Action="LaunchApplication"
After="InstallFinalize">NOT REMOVE~="ALL"</Custom>
<Custom Action="AddHttpsBinding"
Before="InstallFinalize">Not Installed</Custom>
<Custom Action="AddHttpsReservation"
Before="InstallFinalize">Not Installed</Custom>
<Custom Action="DeleteHttpsReservation"
After="InstallInitialize">REMOVE~="ALL"</Custom>
<Custom Action="DeleteHttpsBinding"
After="InstallInitialize">REMOVE~="ALL"</Custom>
</InstallExecuteSequence>
</Product>

<Fragment>
<Directory Id="TARGETDIR"
Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER"
Name="DealingWithThisWixBullshitInstaller" />
</Directory>
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder"
Name="DealingWithThisWixBullshit"/>
</Directory>
</Directory>
</Fragment>

<Fragment>
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="ApplicationShortcut"
Guid="*">
<Shortcut Id="ApplicationStartMenuShortcut"
Name="DealingWithThisWixBullshit"
Description="Dealing with this wix bullshit"
Target="[#DealingWithThisWixBullshitExecutable]"
WorkingDirectory="APPLICATIONROOTDIRECTORY"/>
<RemoveFolder Id="CleanUpShortCut"
Directory="ApplicationProgramsFolder"
On="uninstall"/>
<RegistryValue Root="HKCU"
Key="Software\Microsoft\DealingWithThisWixBullshit"
Name="installed"
Type="integer"
Value="1"
KeyPath="yes"/>
</Component>
</DirectoryRef>
</Fragment>

<Fragment>
<Binary Id="CACert"
SourceFile="muhfakecert.pfx"/>
</Fragment>

<Fragment>
<ComponentGroup Id="ProductComponents"
Directory="INSTALLFOLDER">
<Component Id="ProductComponent">
<File Id="DealingWithThisWixBullshitExecutable"
Vital="yes"
Source="$(var.DealingWithThisWixBullshit.TargetDir)DealingWithThisWixBullshit.exe"
Checksum="yes" >
</File>
<File Id="readme"
Source="$(var.DealingWithThisWixBullshit.TargetDir)readme.txt"
Checksum="yes" >
</File>
<iis:Certificate Id="CACert"
Name="CACert"
Overwrite="yes"
StoreLocation="localMachine"
StoreName="my"
PFXPassword="I HATE YOUR FACE AND I HOPE YOU DIE!"
BinaryKey="CACert"/>
</Component>
<ComponentRef Id="ApplicationShortcut"/>
</ComponentGroup>
</Fragment>
</Wix>

最佳答案

您是否尝试过将最后两个自定义操作的 Return 更改为“忽略”或“检查”?我的猜测是 netsh 命令在您的证书名称和安装文件夹 (??) 之间找到了一些映射,并保持该目录处于打开状态,因此安装程序无法删除它,因为它在某处打开。 asyncWait 会保持一些进程直到安装结束,然后在最后检查返回码。如果您使用“忽略”或“检查”,它将同步运行,当您要删除安装文件夹时,没有任何东西可以保持路径打开,因此可以将其删除。

只是移动评论来回答。不完全确定此处使用的实际机制,但似乎通过某种方法 netsh 最终打开了目录上的句柄,因此在卸载期间无法将其删除。

关于wix - 我鄙视WIX,我要WIX死(真题: can't run custom action and delete a folder at the same time),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43943770/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com