On uninstallation, the installer removes the installed folder and all its subdirectories. However, we want to retain some log files regarding the uninstallation. How do I make the installer not remove the installed folder?
My recommendation would be for the log files to be stored under a folder in %APPDATA%, that is created when required by the application, rather than the installer. As the folder would not be created by the installer, this would resolve the problem of the installer removing it.
It's also worth mentioning that if the installer is creating a folder under %PROGRAMFILES% for your application and you're keeping the log files there, you're doing the wrong thing, as it's not the correct place to store log data because:
%PROGRAMFILES% is not writable for standard users
%APPDATA% is the "correct" place to store things such as logs (it's all in the name! =)
Have you written files to the folder at this point, or just assuming the directory will be deleted since you see it being deleted today (without an new files in it). From my experience, the MSI will not remove a folder that is not empty. So the MSI will remove its own files, but the log files will be in there, thus it will not remove the directory.
I agree with #Rob though, this is most likely not the best location to be writing the log files.
Related
I want to make backup of my application config files. This files are in specified directory. All i want to do is make subdirectory of this directory, and move there this config files on uninstall.
I know that this is possible with WiX custom action, but i think, that there is the simpler way.
I can do this scenario with CopyFile WIX element, but i don't know how to fire it at uninstalling only.
A common way to do this is have the application make a copy of the config file when it first runs, and the copied file is updated and used by the application. The uninstall doesn't remove it (because it didn't install it) but it can be optionally removed with a RemoveFile element or a custom action (and removing with a CA is more straightforward than copying).
One of the reasons this technique is used is that individual config files might be required for each user. In these cases the template installed file is copied by the app to per user locations. Another reason is upgrades and patches. Careless patches and updates can overwrite the original file (because REINSTALLMODE=vamus is used). Also upgrades can be used to deliver updated config files without jumping through hoops figuring out how to preserve the existing config file and yet deliver the new one at install time - the older unchanged template config file can be replaced without impacting current app settings.
Here. Custom action which triggered only on ununstall.
<Custom Action='CREATE_BACKUP' Before='...'>REMOVE="ALL"</Custom>
I have a wix installer for a project I have recently completed.
I am wanting the installer to also check if a current folder structure exists elsewhere on the target computer, and if not then create it. Other applications may have already created some or all of the new structure.
So for example. I install to c:\Programs, but I have an additional folder in c:\HomeMadeApps\ThisApp with a number for folders in there like reports, exports etc. It's likely c:\HomeMadeApps will exist, but not guaranteed, so I just want to add the folders (empty) if they don't already exist.
Would anyone be able to point out how I should go about doing this? This is my first time using wix and I'm not 100% sure?
Thanks
If the directory already exists, the installer will simply install to it. If they don't, the directories will get created.
I've just tested this to confirm.
The existing contents of the directories are only overwritten if the files have the same name as those added by the installer.
My C# program has an app.exe.config file. User can install the program anywhere. If the user chooses to install the program in the "Program Files" folder, the program will have privilege problems modifying files in Windows 7, so I've externalized the files that can be modified to the AppData folder. Except app.exe.config file, that should also be modifiable by the program when user changes its settings. Apparently it should be in the same folder as where app.exe.
I think this is a quite trivial problem, however I cannot find the right solution.
Copying the config file elsewhere, modifying it and copying back to Program Files;
Creating a second config file elsewhere;
Not giving the user the choice of installation folder;
Forcing the program to be run as admin.
All of these solutions would lead to a bad design. What solution wouldn't?
EDIT: Maybe some of my premises are wrong and it is possible to have the config file installed to AppData or anywhere else without changing the executable's location. I haven't yet found for sure if this is possible, however.
The Application Settings Architecture should help you - you can define user settings as well as application settings that are stored in a user.config file.
Reference to MSDN: http://msdn.microsoft.com/en-us/library/0zszyc6e(v=vs.110).aspx
"Non-default user-scoped settings are stored in a new file, user.config, where user is the user name of the person currently executing the application. You can specify a default for a user-scoped setting with DefaultSettingValueAttribute. Because user-scoped settings often change during application execution, user.config is always read/write."
Change app.config file permissions upon installation. If you are using WIX (I'm just assuming since it's the most popular solution nowadays) have a look at http://wixtoolset.org/documentation/manual/v3/xsd/util/permissionex.html
I'm developing a Web application that uses a couple XML files to store data. I have their Build Action set to Content, and on install the files are copied successfully to the Applications Virtual Directory:
C:\inetpub\wwwroot\ApplicationName\
The problem I'm having is that writing to these XML files (in order to save settings and things like that) causes a lot of write permissions issues. Therefore to get around it, I'm trying to copy these files from the virtual directory they're installed to to a new directory under the C drive, using the following PostBuildEvent in the Web Deployment Project:
xcopy "$(TargetDir)*.xml" "C:\CompanyName\ApplicationName\" /y
However, this does nothing. I'm not sure if this is because PostBuildEvents in the installer are not actually fired on install, but only on building the installer, or if TargetDir represents the bin directory:
C:\inetpub\wwwroot\ApplicationName\bin\
instead of the root application virtual directory:
C:\inetpub\wwwroot\ApplicationName\
Does anyone have any ideas? Has anyone dealt with this sort of thing before? I'm really stumped on this one.
Update:
I included a PostBuildEvent that should give full permissions to all users:
icacls "$(TargetDir)" /grant Users:F
But it doesn't seem to have resolved the problem.
I'm also unsure where exactly $(TargetDir) if pointing to, if it would be ..\ApplicationName\ or ..\ApplicationName\bin\
All you have to do is give full permissions to the user under whose context the Web Application Pool runs.
You can find this user by starting IIS manager and look at the Application Pools and Identity column
Something like
cacls C:\inetpub\wwwroot\ApplicationName /G Users:F
will give all permissions to this subdirectory to all users on the computer, If you are running under ApplicationPoolIndentity refer here
Turns out there's a much easier way to do what I was trying to do.
Instead of using PostBuildEvents to create a new directory structure and move files there, I added the new directory structure into
InstallerProject > View > File System
after which I located the Content Files from SomeProject entry in my installer project, and changed the Folder value to the newly specified directory structure, in this case
C:\CompanyName\ApplicationName\
This seems to work fine, I'm now able to access these files freely as I originally intended.
I have built a C#.NET WinForms App. I now need to build a MSI installer for the same so that I can ship it to my clients.
I am stuck at the following place.
I use log4net for Logging. How do I write my App.Config in such a way that the LogFile folder is based on where my end user installs the Application. That is, if my end user installs it on the Default Location of C:\Program Files\\, then the LogFile folder will be C:\Program Files\\*LogFiles*.
If they chose to install it elsewhere, the LogFiles folder will be a sub-folder of the MyApp folder.
Similarly, I have a TemporaryFiles Folder where I store the temporary files while I am modifying the original files. This again should be a sub-folder of the MyApp Folder.
I also understand that the Application Folder points to the [ProgramFilesFolder][Manufacturer][ProductName], where does the CommonFiles folder point to? And typically what goes inside that?
I use VS2008 for Building the Setup.
I would simply not have the log files in the program files folder. The process needs write permissions on it and generally you would only want administrators to have write permissions on the program files folder or any of its subfolders. I would rather consider using e.g. %appdata%/yourapplication/logfiles. Then you could easily have your log4net config point to that location, regardless of where this will be set up. I would do the same thing for the temporary files.
(I don't have an answer to that CommonFiles question.)