PackageGroup Element | WiX Toolset
在我们的项目中 IS项目的产出,由msi和exe共同组成 他们先后有严格的执行顺序
项目升级
如果两个项目upgradeCode相同, 执行高版本ProductVersion,日志中将会出现
<Bundle Version="$(var.ProductVersion)"
Name="IS Extension"
UpgradeCode="$(var.UpgradeGuid)"
DisableModify="button"
IconSourceFile="$(var.IconFile)">
<Chain>
<PackageGroupRef Id="ssdt_is" />
</Chain>
</Bundle>
[23F0:0B94][2022-12-22T10:08:39]i102: Detected related bundle: {16362d70-d910-4542-872f-17a05a422a6b}, type: Upgrade, scope: PerMachine, version: 16.0.948.0, operation: MajorUpgrade
并且在高版本的依赖链执行完成之后,调起一个新的进程,使用缓存16362d70-d910-4542-872f-17a05a422a6b执行卸载操作
[5778:34E8][2022-12-22T04:55:08]i001: Burn v3.7.1224.0, Windows v6.2 (Build 9200: Service Pack 0), path: C:\ProgramData\Package Cache\{54e42c7e-524f-412c-928f-ca610b452466}\Microsoft.DataTools.IntegrationServices.exe, cmdline: '-uninstall -quiet -burn.related.upgrade -burn.embedded BurnPipe.{9AFE5A7F-3E29-47BA-BF36-921FF48355E6} {38C48158-451E-4993-BB73-8234FEE85445} 22892 -burn.unelevated BurnPipe.{939A69FB-EEF5-44C7-B0C9-3D914B7E0CA5} {867142AD-DDE2-4454-B146-DE51E39EA1F6} 14560'
[5778:34E8][2022-12-22T04:55:08]i003: This bundle is being run by a related bundle as type 'Upgrade'.
[5778:34E8][2022-12-22T04:55:08]i000: Initializing string variable 'ProductVersionVar' to value '16.0.948.0'
项目卸载
由于我们是VS的一个extension,所以会存在一台机器上是两个我们的项目的情况,比如一个是VS2019 community extension,一个是VS2019 profession extension。
如果我现在要卸载community extension
<Fragment>
<PackageGroup Id="ssdt_is">
<ExePackage
Id="ISVsix"
SourceFile="$(var.PayloadDropFolder)\SSDTIS\SSISOneDesignerDependencies\VSIXBootstrapper.exe"
PerMachine="yes"
InstallCondition="VsixRequired = 1"
DetectCondition="VsixInstalled = 1"
InstallCommand="/q /admin /instanceIds:"[InstanceIds]" /logFile:"[WixBundleLog_ISVsix]" "payload\Microsoft.DataTools.IntegrationServices.vsix""
RepairCommand="/q /admin /instanceIds:"[InstanceIds]" /logFile:"[WixBundleLog_ISVsix]" "payload\Microsoft.DataTools.IntegrationServices.vsix""
UninstallCommand="/q /admin /instanceIds:"[InstanceIds]" /logFile:"[WixBundleLog_ISVsix]" /u:$(var.VSIXGuid)">
<PayloadGroupRef Id="ISVsix"/>
<dep:Provides Key="ISVsix" Version="1.0.0.0" />
</ExePackage>
<MsiPackage
Id="SSDTISSingleton150"
DisplayName="SQL Server Integration Services Singleton"
Cache="yes"
Name="payload\SSDTISSingleton150.msi"
SourceFile="$(var.PayloadDropFolder)\SSISOneDesigner2019\packages\SSDTISSingleton150.msi"
Vital="yes"
Visible="no"
Compressed="$(var.IsCompressed)">
</MsiPackage>
</PackageGroup>
</Fragment>
在上图两个例子里,SQL Server Integration Services Singleton MSI是共用的,只要他们版本号一致,在还有profession在用它的情况下,它确实不应该被删除。
但是ISVsix不一样,它是community和profession各自都独一份的存在,这个uninstallcommand是需要被卸载的,但是由于现在他们
Provides Key
相同,导致uninstall的命令无法被真正的执行。
[3B58:3388][2022-11-25T09:57:13]w327: Will not uninstall package: ISVsix, found dependents: 1
[3B58:3388][2022-11-25T09:57:13]w328: Found dependent: {5c7377e0-707d-4f25-b61a-f5c682e6c5d0}, name: Microsoft SQL Server Integration Services Projects
这个问题的解决方法目前我并没有想到,也因此,workaround是项目中一旦卸载, 将会把2019 community和profession同时卸载。同时对VS2022, Provides Key
重新命名为ISVsix2022。注意,如果只是改version不改key是无用的。