Add another folder structure with Wix installer - c#

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.

Related

Primary output is "obj" folder instead of "bin"

I am trying to create installer file by Visual Studio 2015 Installer.
When I add Primary output from <project name> into Application Folder, it point to files in obj folder instead of bin folder.
After installed, I can NOT start my application. I think the reason come from "obj/Release".
Please refer to attached image for more information:
Why? How can I change it to bin folder?
The easiest thing to do is to forget about primary output and just add the files you want by browsing to them from the IDE's File System view, especially if it's just one or two files, and it typically help to see the files you're installing and know exactly what you're doing. Also, note that other files (such as data files) should most likely be installed to user's application data (not Application Folder), and shared Dlls might need to be in common files folder, and assemblies into the GAC. Using primary output tends to gloss over this kind of detail.

Make config files backup at product uninstall - WIX, .NET, C#

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>

How to copy built assemblies into a project resource folder?

In the Resources folder of my project, I have many different DLLs from other assemblies in my solution. These DLLs are used as embedded resources so I can have a single EXE without having to have local copies of all the DLLs. What I want to be able to do is have them updated every time I build my entire solution. So for example, if I have AssemblyOne/bin/x86/Debug/Foo.dll, I want the DLL to always copy over to LocalAssembly/Resources/Foo.dll whenever I build the project.
Is there an easy way to do this? I was looking at the post-build-event macros, but none of them would be able to directly reference my "LocalAssembly", which is not the Solution Directory. Also, I'm not sure how I would go about writing a new custom post-build command in a way that the newly copied DLLs would not be an absolute reference to my local machine. Thanks! Please comment for more information and I will edit the question.
You need not access only your solution folder in post build events. The post build scripts run with whatever permissions the compiler had when it ran. Since in Visual Studio things frequently run with Administrator permissions, chances are great you have access to your entire file system. As a result, if you are wanting to copy resources around, you merely need to presume that you are starting the xcopy call in the build destination directory. From there, you can navigate around with normal paths. So if, for example, you needed go up three levels and then into the directory LocalAssemblies, your copy command would look like xcopy Foo.dll ../../../LocalAssemblies.

MSI uninstallation not to remove all the folders

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.

Custom c# installer class

I'm trying to install some folders along with my app - folders with help files. How should I do that? Right now I've added two files to a setup projects as assemblies, though I don't know how to get to those files in the Install method of my installer class, and copy them to correct folders...
I even don't know if those files are being added to installer, so if someone would explain me how to install custom files along with my application - step by step, I would be grateful.
You can add a setup project to your project and mention what all items should be copied to the destination install directory when you install it. I did the same thing and written it here for anyone wish to do it.
http://www.techiesweb.net/2008/07/setting-path-while-installing-an-application-visual-studio-2005-setup-project/
Hope this helps

Categories