UI中的属性更改将从卸载日志中消失。
如果我使用默认属性值安装我的应用程序,然后运行卸载,则该属性将显示在卸载日志中。
如果我在卸载时从UI更改属性值,它不会出现在日志中。
这就是为什么apppool和webapp在卸载后仍然保留在IIS中的原因,这与默认值不同。
<Property Id="WEB_APP_NAME" Value="WebApp" Secure="yes" />
这是属性的样子。
这是我从UI控件添加一个值的地方
<Control Id="PoolNameEdit"
Type="Edit"
X="100"
Y="45"
Width="160"
Height="17"
Property="WEB_APP_NAME"
Text="{80}"
Indirect="no" />
这就是我使用它的方式
<!-- Define the directory structure -->
<Fragment>
<!--Directory elemens hierarchy always starts with Id="TARGETDIR" Name="SourceDir"-->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="WEB_APP_FOLDER_LOC" Name="WebInstaller">
<Directory Id="WEBFOLDER" Name ="[WEB_APP_NAME]" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<!--Concatenate user input for folderpath-->
<SetDirectory Id="WEBFOLDER"
Value="[WEB_APP_FOLDER_LOC][WEB_APP_NAME]"
Sequence="both" />
<!--Create new folder-->
<DirectoryRef Id="WEBFOLDER">
<Component Id="cmp_WebDir"
Guid="{E0CE5051-1419-4997-949F-020BC814ECDA}"
KeyPath="yes">
<CreateFolder />
</Component>
</DirectoryRef>
<!--Components-->
<ComponentGroup Id="ProductComponents" Directory="WEBFOLDER">
<!--Client config-->
<Component Id="cmpWebConfig"
Guid="{1C84DF1F-2EA4-46E6-8125-C6FD410AFED9}"
KeyPath="yes">
<Condition>INCLUDECONFIGFILE="1"</Condition>
<File Source="Configuration\Web.config" />
</Component>
<!--Application pool-->
<Component Id="cmpAppPool"
Guid="{00D6ABB1-734F-4788-ADB8-12A30056C513}"
KeyPath="yes">
<iis:WebAppPool Id="MyAppPool"
Name="[WEB_APP_NAME]"
ManagedRuntimeVersion="v4.0"
ManagedPipelineMode="integrated"
Identity="applicationPoolIdentity" />
</Component>
<!--Website-->
<Component Id="cmpMyWebsite"
Guid="{ECD42015-C067-44F3-94D9-5E713BCB586D}"
KeyPath="yes">
<iis:WebSite Id="website_MyWebsite"
Description="[WEB_APP_NAME]"
Directory="WEBFOLDER"
ConfigureIfExists="no">
<iis:WebApplication Id="webapplication_MyWebsite"
Name="[WEB_APP_NAME]"
WebAppPool="MyAppPool" />
<iis:WebAddress Id="webaddress_MyWebsite"
Port="[WEB_APP_PORT]" />
</iis:WebSite>
</Component>
我希望在UI中更改WEB_APP_NAME后,卸载程序能够找到它,从而从IIS中删除appool和webapp。
Property(S): VirtualMemory = 3353
Property(S): UpgradeCode = {A4F9CA9E-4135-4D6F-AF58-FADA49E265DA}
Property(S): ConfigureIIs7Exec = **********
Property(S): StartIIS7ConfigTransaction = **********
Property(S): RollbackIIS7ConfigTransaction = **********
Property(S): CommitIIS7ConfigTransaction = **********
Property(S): WriteIIS7ConfigChanges = **********
Property(S): NETFRAMEWORK45 = #461808
Property(S): WEBFOLDER= C:\inetpub\WebApp\
Property(S): WEB_APP_FOLDER_LOC = C:\inetpub\
Property(S): WEB_APP_NAME = WebApp
Property(S): WEB_APP_PORT = 8080
Property(S): WEB_APP_USERNAME = ******
Property(S): WEB_APP_DOMAIN_NAME = ******
Property(S): WEB_APP_SQLSERVER_NAME = ******
Property(S): INCLUDECONFIGFILE = 1
这是默认卸载日志的样子,如果我将WEB_APP_NAME更改为其他内容,则在卸载日志中找不到WEB_APP_NAME,上面可以看到它?
感谢任何可以解决这个问题的想法!
注意:请至少在卸载期间阻止属性更改。我认为您应该只接受全新安装时的更改?还是重大升级?否则,已解析的目录名称与已安装的目录名称不匹配(您最初遇到的问题)。
持久属性:当您允许在设置GUI中或通过命令行显示和更改相关属性时,需要保留相关属性。否则,当解析为目录或应用程序名称时,属性将为空白 - 或者在您的设置中使用它们的任何容量。持久的MSI属性不是内置的Windows Installer功能(只有少数系统属性会自动保留)。通常是MSI反模式,但就是这样。
“记住模式”示例:对于常规,PUBLIC属性(UPPERCASE属性),您可以使用Rob Mensching's remember pattern来保存和检索属性值,以进行修复,修改,卸载和其他维护操作。这里使用了这个属性持久性模式的一小部分样本:WIX UI for multiple target directories(记住使用中的模式)。
安装模式:安装时需要检查许多安装模式:fresh install
,repair
,modify
,self-repair
,uninstall
,major upgrade uninstall
,patching
,rollback
,resume suspended
(重启和其他原因)等等......我至少会测试一下前6种类型 - 确保分辨率正常工作。
这里要理解的关键是Windows Installer不保存Property值。在修复,升级或卸载期间,用户输入的值(通过UI或通过命令行参数)将不可用。您可以想象,它在卸载期间可用,这是一个简单的问题,但这就是Windows安装程序的工作方式。绕过这个的最简单的解决方案是读取属性,然后将其写入注册表。在修复/卸载/升级期间,执行RegistrySearch并根据注册表中的内容使用该值。
至于为什么在卸载期间保留默认值,那是因为初始/默认值被添加到MSI Property table。并且在卸载期间也会从属性表中使用相同的值。