Post-Install adding files to avoid the .MSI AutoRepair feature - c#

I am unsure how to phrase the title - which may be incorrect - so I will attempt to elaborate here.
The problem: .MSI installer auto repairs missing files (images) after manually deleting them from the directory.
What I want: I need my application to install a bunch of icons into the directory. These icons are considered "default" Icons and the user can, if they want, remove them from the directory. When the user removes them from the directory, I don't want the .MSI installer to "Auto Repair" them back into the directory.
I am not sure the best way to handle this situation. Any programming advice will be taken seriously.
Thanks for your time.

I think you can set the ComponentId to null https://msdn.microsoft.com/en-us/library/aa368007(VS.85).aspx

Related

WiX Installer - how to read sql file content from a folder which reside at same location as .msi

I want to invoke custom action to execute set of .sql files against given database. I am able to do that using custom action code(in c#) if I hardcode path of folder where my sql files are available.
I want to put this sql scripts folder in same location where my .msi is present. How can I access/find this folder-path from custom action during the time of installation?
I am using Wix 3.6.
I am using dot net bootstrapper to create my setup.exe.
The SqlScript element in the WiX toolset may do a lot of what you are asking for. It actually stores the scripts as Binary streams in the MSI instead of relying on files relative to the MSI. This is an important design decision because there are many cases where your MSI will execute but not have access to the original source media so it would not find the scripts. For example, repair operations can be launched from the cached MSI package. If your custom action was to repair, it would need the original media to get the scripts. This is not very desirable.
If you really want to go down this path, then you'll want to look at using the SourceDir directory to get the "source location" of your MSI. As noted above, the source media may not always be available and SourceDir will be blank in those cases. To force SourceDir to be set, you'll need to add a ResolveFiles action. Be careful when scheduling ResolveFiles because that will require the original media. If that can't be found, the user will be prompted to insert it again.
The worst case of poor sequencing of ResolveFiles is a prompt from source when the user is attempting to uninstall their product. User's are trying to get your application of the machine and they are prevented unless they can find how they originally installed it. Good way to really upset your users. :)
I highly recommend looking at the SqlScript element instead or the source code if you are really interested. It's in the WiX toolset at src\ca\serverca (look for files with "sql" in the name below there).

For a WPF application, what files do I need to share the source code?

Having created a WPF/C# demo application (in Visual C# Studio Express), what are the minimum files I would need to zip up, to give the source to someone? (Not deploy an executable, but enough actual source code to recreate the project).
Obviously I need the *.xaml *.cs *.sln *.csproj files.
Do I need *.suo *.csproj.user, or are those specific to my editor?
Do I need any or all of the files in the Properties directory? Some of those files say auto-generated, which would seem to imply they're not needed.
I'd share the Properties files as well, it generally being a good idea to share and version all files that are needed to compile the project regardless of the IDE. Since it's an IDE tool that generates those files, I'd consider it bad form to leave them out, in case you want to set up a Continuous Integration server or something of that sort.
The *.suo files are Solution User Options, which kind of implies that they're per-user, not per-project. Same goes for the *.user files.
the simplest thing is to delete any obj/bin directories (if they exist), and just zip up everything else.
the .user and .suo are things that will get recreated, but there's no harm in sending them (unless they are really big!)
That being said, it really depends on the details of your project, and how you have it organized.

How to detect the install directory of a project?

I have a Visual studio C# project and I have an installer that installs the files into whatever directory the user specifies. I also have another installer with localized language resources and I want that to be installed in the aforementioned directory.
Can anyone point me in the right direction on this? I think I have to do something with registry keys but I don't know what to do.
Edit: For the record, I found this page: How to: Use a Registry Launch Condition to Specify a Target Directory. And I followed the instructions and it did what I wanted it to do.
Typically, you would create a registry subkey and value of HKEY_LOCAL_MACHINE\SOFTWARE\ and then just read that key back in your second installer to decide where to put that.
Something like HKLM\SOFTWARE\MyApplication,
Then you make a string value called InstallPath and write the path from your first installer there.
Depending on what you're doing, you may want to have a look at merge modules for installing several components with one MSI.
You are on the right track. Your first installer would write it's install path to a well known registry key. The second installer would read the path from that well known key and put it's dlls in the appropriate sub folders.
Here is one way to go at it:
Assembly a = Assembly.GetExecutingAssembly();
string folder = System.IO.Path.GetDirectoryName(a.CodeBase);

how can create specific folder when install setup file?

I want to make setup for my project and i have one folder "Resource"
in this path ..\bin\Debug.now how can i make setup file ,that when
i install setup "Resource" folder with it's files become created in the
install folder ?
my database is sqlexpress for my database file what
should i do?it's folder is App_Data in ..\bin\Debug path.Thanks in Advance.
If you are going to be creating more than just this one setup I would recommend looking into the WiX Toolkit. It is an XML based toolkit that will let you create your MSI's with an amazing amount of customization. Placing the folders that you need where you need them is no problem at all. I think that might just be what you are looking for. Also the link that I included has a link to a really great tutorial that would help you get started.

Deploying with a folder structure

Good day all,
I have written an application that i require to have a certain directory structure/. Nothing complex but it will need an "Images" Folder which contains two other folders "Temp" and "Complete".
These folders are in my solution however upon publishing all the folders are gone and i can not find any way in which to cause these certain folders to persist.
Will i have to write some code that checks if these exist and create them or can i make an application directory structure exist from the very beginning.
Dont know if this is relevant but i am using WPF and deploying through click-once.
Thanks,
Kohan
Regardless of whether you find a solution to the installation part of your question it would be prudent to check that the folders exist either on application start up or when you need to access them. After all, someone could come along and delete them without realising that they're needed. You might want to report or log this as an error, but recreate them anyway.
I assume you are using Visual Studio to create your ClickOnce deployments. If so, you can get around this issue by using MageUI instead.
Create your desired folder structure separate from you project's source code and bin folders. Copy in all the files you want deployed. Use MageUI and when you create the application manifest, point it to the root folder you created. It will take care of all the subfolders.
Also, I wouldn't worry too much about what ChrisF said. ClickOnce files are deployed to a very obfuscated location that users should never be in. And if they are in there deleting stuff, you'll likely have much bigger problems that a missing subfolder.

Categories

Resources