问题
We have multiple configuration files. Based on the environment selected, right file gets copied and the rest of the files should get deleted.
I am using RemoveFile
but that doesn't delete anything or may be I am not using it right. Can someone give an example to delete *.config
from [INSTALLDIR]
during the install, after all files have been copied.
回答1:
In the example below RemoveFile
is used to delete all icons (.lnk
extension) on uninstallation, also the parent folder will be removed by using RemoveFolder
<DirectoryRef Id="DirName">
<Component Id="cmpName" Guid="{429BC364-BE5F-4EC8-9AB9-8A522F8EC089}">
<RemoveFile Id="removeDesktopShortcuts" On ="uninstall" Name="*.lnk"/>
<RemoveFolder Id="RemoveFolder1" On="uninstall"/>
</Component>
</DirectoryRef>
回答2:
Why don't you go with option of custom action. Create a method in C# or other and then call it after 'InstallFinalize'.
Example :
[CustomAction]
public static ActionResult RemoveConfigs(Session session)
{
string configfiles = "\"" + session["INSTALLDIR"].ToString() + "*.config\"" ;
System.Diagnostics.Process.Start("cmd.exe", "/C del " + configfiles);
return ActionResult.Success;
}
In CustomAction.wxs add
<Custom Action="ZA_RemoveConfigs" After="InstallFinalize">NOT INSTALLED AND NOT REMOVE</Custom>
来源:https://stackoverflow.com/questions/7176188/wix-how-to-use-removefiles