2016-08-17 75 views
-1

我有一個wix安裝程序,它將sqlclr安裝到數據庫中。我正在使用sqlcmd來運行腳本。WIX在卸載過程中運行sqlcmd

我還想在用戶刪除應用程序時刪除sqlclr。 這是我迄今爲止,它似乎並沒有工作。

<InstallExecuteSequence> 
    <Custom Action="sqlcmd.install" After="InstallFiles">NOT Installed</Custom> 
    <!--Ensure this runs after the CA to set up the property for its cmd line--> 
    <Custom Action="sqlcmd" After="sqlcmd.install">NOT Installed</Custom> 
    <Custom Action="NewerVersion" After="FindRelatedProducts">NEWERVERSIONDETECTED</Custom> 
    <RemoveExistingProducts After="InstallInitialize" /> 
    <Custom Action="sqlcmd.uninstall" After="InstallInitialize">Installed AND NOT UPGRADINGPRODUCTCODE</Custom> 
</InstallExecuteSequence> 
<!--Find sqlcmd.exe path--> 
<Property Id="SQLBINDIR"> 
    <RegistrySearch Id="SqlBinDir" Root="HKLM" Key="SOFTWARE\Microsoft\Microsoft SQL Server\90\Tools\ClientSetup" Name="Path" Type="raw" /> 
</Property> 
<!--Need to use "property" CA to get variable substitution--> 
<CustomAction Id="sqlcmd.install" Property="sqlcmd" Value="&quot;[SQLBINDIR]sqlcmd.exe&quot; -S [SQLSERVER] -d [SQLDATABASE] -U [SQLUSER] -P [SQLPASSWORD] -i &quot;[#Install.sql]&quot; -v PROGRAMDIR=&quot;[APPLICATIONFOLDER]&quot;" /> 
<!--Note that the cmd line and args will come from a property with the same name as the CA, this has been set by the CA above--> 
<CustomAction Id="sqlcmd" BinaryKey="WixCA" DllEntry="CAQuietExec" Return="check" Execute="deferred" Impersonate="yes" /> 
<CustomAction Id="sqlcmd.uninstall" Property="sqlcmd" Value="&quot;[SQLBINDIR]sqlcmd.exe&quot; -S [SQLSERVER] -d [SQLDATABASE] -U [SQLUSER] -P [SQLPASSWORD] -i &quot;[#Uninstall.sql]&quot;" /> 

回答

0

這裏是對任何感興趣的人的修復。

似乎我的卸載遇到雞或雞蛋問題。 我的uninstall.sql文件在執行sqlcmd之前被刪除。 所以我在RemoveFiles之前將卸載更改爲occure。

<InstallExecuteSequence> 

    <Custom Action="installcmd.install" After="InstallFiles">NOT Installed</Custom> 
    <!--Ensure this runs after the CA to set up the property for its cmd line--> 
    <Custom Action="installcmd" After="installcmd.install">NOT Installed</Custom> 

    <Custom Action="uninstallcmd.uninstall" Before="RemoveFiles">Installed AND NOT REINSTALL</Custom> 
    <!--Ensure this runs after the CA to set up the property for its cmd line--> 
    <Custom Action="uninstallcmd" After="uninstallcmd.uninstall">Installed AND NOT REINSTALL</Custom> 

    <Custom Action="NewerVersion" After="FindRelatedProducts">NEWERVERSIONDETECTED</Custom> 
    <RemoveExistingProducts After="InstallInitialize"/> 

</InstallExecuteSequence> 



<!--Find sqlcmd.exe path--> 
<Property Id="SQLBINDIR"> 
    <RegistrySearch Id="SqlBinDir" Root="HKLM" Key="SOFTWARE\Microsoft\Microsoft SQL Server\130\Tools\ClientSetup" Name="Path" Type="raw" /> 
</Property> 

<!--Need to use "property" CA to get variable substitution--> 
<CustomAction Id="installcmd.install" Property="installcmd" Value="&quot;[SQLBINDIR]sqlcmd.exe&quot; -S [SQLSERVER] -d [SQLDATABASE] -U [SQLUSER] -P [SQLPASSWORD] -i &quot;[#Install.sql]&quot; -v PROGRAMDIR=&quot;[PROGRAMDIR]&quot;" /> 
<!--Note that the cmd line and args will come from a property with the same name as the CA, this has been set by the CA above--> 
<CustomAction Id="installcmd" BinaryKey="WixCA" DllEntry="CAQuietExec" Return="check" Execute="deferred" Impersonate="yes" /> 

<CustomAction Id="uninstallcmd.uninstall" Property="uninstallcmd" Value="&quot;[SQLBINDIR]sqlcmd.exe&quot; -S [SQLSERVER] -d [SQLDATABASE] -U [SQLUSER] -P [SQLPASSWORD] -i &quot;[#Uninstall.sql]&quot;" /> 
<!--Note that the cmd line and args will come from a property with the same name as the CA, this has been set by the CA above--> 
<CustomAction Id="uninstallcmd" BinaryKey="WixCA" DllEntry="CAQuietExec" Return="check" Execute="deferred" Impersonate="yes" />