如果在安装时未设置这些属性,为什么在卸载时会忽略这些属性? [英] Why are properties ignored on uninstallation, if they have not been set on installation?
问题描述
我创建了一个安装程序,它使用 WixSqlExtension 提供的 sqlstring 元素安装数据库.下面是代码示例:
I have creeated an installer, which installs a database using the sqlstring element provided by the WixSqlExtension. Here is a sample of the code:
<ComponentGroup Id="DatabaseCreation" Directory="INSTALLFOLDER">
<Component Id="CreateDatabase" Guid="SOMEGUID" KeyPath="yes">
<sql:SqlString
Id="CreateDB"
Sequence="1"
ExecuteOnInstall="yes"
ContinueOnError="no"
SqlDb="MasterDB"
SQL="DECLARE @dbname nvarchar(128)
SET @dbname = N'{[SQLDATABASE]}'
IF(NOT EXISTS
(SELECT name
FROM master.dbo.sysdatabases
WHERE ('[\[]' + name + '[\]]') = @dbname
OR name = @dbname
)
)
CREATE DATABASE {[SQLDATABASE]}"
/>
</Component>
<Component Id="DropDatabase" Guid="ANOTHERGUID" KeyPath="yes">
<sql:SqlString
Id="DropDB"
Sequence="10000"
SqlDb="MasterDB"
ExecuteOnUninstall="yes"
ContinueOnError="no"
SQL="DECLARE @dbname nvarchar(128)
SET @dbname = N'{[SQLDATABASE]}'
IF(EXISTS
(SELECT name
FROM master.dbo.sysdatabases
WHERE ('[\[]' + name + '[\]]') = @dbname
OR name = @dbname
)
)
DROP DATABASE {[SQLDATABASE]}"/>
<Condition>
<![CDATA[DROPDATABASE = "1"]]>
</Condition>
</Component>
</ComponentGroup>
使用以下命令安装软件包后
After installing the package with the following command
msiexec /i package.msi /l*v install.log
数据库已按预期创建.但是使用命令卸载包
the database is created as expected. But uninstalling the package with the command
msiexec /x package.msi DROPDATABASE="1" /l*v uninstall.log
不会按预期删除数据库.奇怪的是,该属性似乎已设置,如 uninstall.log 中所述:
does not drop the database as expected. Curiously, the property seems to be set, as documented in uninstall.log:
[...] MSI (s) (44:68) [14:42:12:442]: Command Line: DROPDATABASE=1 REMOVE=ALL CURRENTDIRECTORY=C:\install CLIENTUILEVEL=2 CLIENTPROCESSID=2532[...]
[...] MSI (s) (44:68) [14:42:12:462]: PROPERTY CHANGE: Adding DROPDATABASE property. Its value is '1'.[...]
[...]Property(S): MsiHiddenProperties = CreateDatabase;DropDatabase;ExecuteSqlStrings;RollbackCreateDatabase;RollbackExecuteSqlStrings[...]
[...]Property(S): DROPDATABASE = 1[...]
现在是最有趣的部分:使用以下命令安装软件包时:
Now to the most interesting part: When installing the package with the following command:
msiexec /i package.msi DROPDATABASE="1" /l*v install.log
使用以下命令卸载软件包:
uninstalling the package with the following command:
msiexec /x package.msi DROPDATABASE="0" /l*v uninstall.log
删除数据库.我不明白为什么会这样.此处,为 DROPDATABASE 属性传递了值0",但代码明确指出仅当此属性的值设置为值1"时才删除数据库.再次在日志文件中可以看到该值的赋值:
drops the database. I cannot understand why this is happening. Here, the value "0" is passed for the DROPDATABASE property, but the code clearly states to only drop the database when the value of this property is set to the value "1". The assignment of the value can be seen in the log file again:
[...]MSI (s) (44:44) [14:49:12:587]: PROPERTY CHANGE: Adding DROPDATABASE property. Its value is '0'.[...]
为什么卸载时忽略 DROPDATABASE 属性?MsiHiddenProperties 来自哪里?如何设置卸载的属性?
Why is the DROPDATABASE property ignored on uninstallation? Where do the MsiHiddenProperties come from? How do I set properties for an uninstallation?
推荐答案
默认情况下,Component
Condition
仅在安装期间进行评估.如果您希望在每次执行安装包时评估 Condition
,您需要在 Component
元素上设置 Transitive='yes'
属性.
By default a Component
Condition
is only evaluated during install. If you want the Condition
evaluated every time the installation package is executed you need to set the Transitive='yes'
attribute on the Component
element.
但是,根据我的经验,在卸载过程中,如果 Component
是由 MSI 安装的,它将在卸载 MSI 时被删除.
However, in my experience, during uninstall if the Component
was installed by the MSI it will be removed when the MSI is uninstalled.
MsiHiddenProperties
来自您正在使用的 SQL 自定义操作.它们会阻止 Windows 安装程序记录 SQL 字符串,因为有时 SQL 字符串中有密码,而您不希望日志文件中的密码以纯文本形式存在,从而导致安全漏洞.
The MsiHiddenProperties
comes from the SQL custom actions you are using. They prevent the Windows Installer from logging the SQL strings because sometimes there are passwords in the SQL strings and you don't want the passwords in plain text in log file causing a security vulnerability.
这篇关于如果在安装时未设置这些属性,为什么在卸载时会忽略这些属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!