Self-Extracting Zip: Specify Extraction Path With .exe File
-
22-02-2021 - |
Pergunta
I'm working on a deployment plan for a C# Winforms application and would like to use a self-extracting .zip file to distribute all of the required files. Here is the file structure of the SFX:
Setup.exe
app.exe
app2.exe
readme.txt
manual.pdf
After the user runs the SFX, I want Setup.exe
to take control and copy app.exe
, app2.exe
, readme.txt
, and manual.pdf
to location x
. The path they are copied to will depend on choices the user makes from the UI of Setup.exe
, system properties, etc.
How would I go about writing Setup.exe
in C#?
Solução
Personally, I had very good experiences with using NSIS as a setup tool. It's a bit more than a SFX but really good to use, rather flexible and free-of-charge.
So I recommend that you do not write your own SFX in C# (aka "re-inventing the wheel") but rather use something existing that is real-world-proofen.
There are, of course, a lot of other installers available.
Outras dicas
I agree, don't waste your time writing an installer when there are already ones available. If you did chose to write one on your own for whatever reason, I would encourage you to stay away from any languages that require dependencies (e.g. C# requires the .Net Runtime). I would suggest using C or C++ and turning on static linking using the /MT
flag so that your installer is dependent on as little as possible.
Some of the installation software I've used (in order of preference):
Nullsoft Scriptable Install System (NSIS) - This is a free scripted installer which has a large user base including Firefox, DOSBox, 7-Zip, Winamp, and even Dropbox.
Inno Setup - This one is free, and the project files are setup more like an INI file. Overall, very easy to work with, but not as feature rich as NSIS. There is a visual editor called ISTool which makes it even easier to work with.
Visual Studio Installer / Microsoft Windows Installer - It comes with Visual Studio, and it works well enough. It creates a MSI setup package.
See the list of installation software article on Wikipedia for other options.