Deploy .NET (C#) exe application on desktops - c#

I develop application in C# with MSVC 2010 Express, with Forms/WPF/etc.
Application consist of some private assemblies (maybe DLLs) and .exe file. It uses .NET 4 features.
How I deploy this application to other computers? Of course if they have .NET 4 I just can send zip of .exe with .dlls and it work. But if they don't have .NET at all (on Win XP machine)? Or maybe they have lower version of .NET? Should I point them to install .NET from internet or package it with my app or what?
Thanks

There is click-once deploy from microsoft. It automates most of the tasks, including making sure you have the right .Net version and updating the app if a new version of your app is available.

You should create a installer package. If you are using the express versions of visual studio, you can use some free tools for this like WiX or Inno Setup. WiX is perhaps a difficult option to start with, but has a lot of flexibility. There are tutorials and example projects to modify to adapt them to your needs.
http://www.tramontana.co.hu/wix/
This tools create installers that can check if a certain version of the .NET framework is installed on the user computer, among other conditions. You can also include the .NET redistributable in your package, or point the user to download and install it.

We try to keep deployment as simple as possible, and one of the things we do is to ensure our application is just a single executable, no support files needed.
We several steps to get there:
Make sure all dependent resource files are stored in embedded resources where possible, and not on disk
Use ILmerge to link all assemblies into a single executable
Optional - obfuscate the assembly
Optional - If some parts cannot be ILMerged or obfuscated, forcing us to have multiple files, we use Xenocode's PostBuild to link all files into a single executable. Xenocode offers a virtual filesystem to do this. This also allows framework embedding so your app will run on a clean Windows install - no dependencies need to be installed :-)
Wrap the single executable into an msi installer using WiX
Wrap the single executable into click once deployment. For this we also use a little stub launcher executable which starts the main application, allowing us to reuse the same main application executable
Create a zip file of just the single file executable for manual installation.
We the following on our downloads site:
the MSI installer - we prefer people to use this one
A zip file with the Xenocoded (single file) executable
A zip file with the Xenocoded (single file) executable including the .NET Framework

http://support.microsoft.com/kb/324733

Yes, you should point them to install .NET. Otherwise it won't be possible for them to run your application.

You didn't say what type of clients they are (are you making a small app for your friends to use or are they paying customers), but whatever the case may be, I'm always completely against sending a zip file with an instruction document describing what to do with it and what folder to extract it to. As Remy said, ClickOnce is not a bad idea, but I've found it to be a bit of a pain to set up (once you get it set up, though, it works just fine). On the other hand, a Deployment project is simpler and if I were you, that would be the first thing I'd explore.

Use xenocode here
http://spoon.net/Studio/
No need to install anything.
It converts your exe to Native code indirectly and you can run anywhere on windows system.
It also has some option of adding framework inside and the total exe size will be somewhere arround 10MB + Your application exe size..
Thanks

yes! you have to give some general instruction about prerequisites to run your software and in that you can mention the Framework version 3.5 or 4.0 and other utilities you require.
please refer this document for Choosing a Deployment Strategy in Visual studio 2010 may this can help you
http://msdn.microsoft.com/en-us/library/e2444w33.aspx

when you package you application,you shoud include the .NET Framework

Check out Inno : http://www.jrsoftware.org/isinfo.php
It's free and pretty simple.
OTOH I've seen QTTabBar using it in its' codebase and it was literally one single text file (setup.iss). Let me see if I can find URL to their SourceForge page so you can see the source and the build ... There is it http://qttabbar.svn.sourceforge.net/viewvc/qttabbar/trunk/Install/ If you grab the source tree you can probably re-fit it for your app in a day.

Related

Building Windows Form Application to Standalone Executable

I've never done this before, because I've never needed to until now, but I need to build my windows forms application to a standalone executable. I'm aware of both Build and Publish options within Visual Studio however none do what I need. Build doesn't allow you to move the executable it makes, and Publish makes a setup to install on the computer.
My goal is for the application to open without installation.
In the /bin/Debug/ directory made by the Build option, I have an executable, four dlls required, two .pdb file, and few other standard files (.manifest, .config, etc.). I was hoping to get any requirements built inside the executable.
How do I do this? All my searching has taken me to bunch of tutorials on how to make applications from scratch and how to use the csc.exe console command.
You can merge the separate assemblies to make it one single executable.
There is a tool called ILMerge that is capable of doing that for you. Another method is described in this post, which also works for WPF.
What you want is to embed the .DLLs in the .exe file so you can move it freely and only need the .exe , you just didn't search for the right thing,
here is what you are looking for :
It is possible to merge .NET executables with libraries. There are multiple tools available to get the job done:
ILMerge is a utility that can be used to merge multiple .NET assemblies into a single assembly.
Mono mkbundle, packages an exe and all assemblies with libmono into a single binary package.
IL-Repack is a FLOSS alterantive to ILMerge, with some additional features.
See : Embedding DLLs in a compiled executable
this is indeed a duplicate but i don't have the reputation to mark it as so.

Compiling VS2012 Application to .exe without any sort of installer

Is there a way to publish a VS2012 App (WPF) to an .exe without any installer? I know how to use ClickOnce installers but i was wondering if it could be taken one step furthur.
Many small programs seem to come in a .rar with some app files and an .exe that runs and doesn't have to install. Is this possible in VS2012? (or 2010)
Yes, sure, it's possible. Just compile you app in Release mode and take all you have in Release folder.
This is possible with Visual Studio 2012 depending on your needs and your approach to developing your application. I'll list a couple options, but don't take this as being exhaustive as there are many ways to accomplish the same thing. I'm assuming you want a "1 click" solution for the user.
You can embed all of your application's resources into the application allowing your users to be able to simply download or copy the .exe and run it from anywhere and it "just works".
Pros: The only method that gives you what you asked for. A single .exe without the need for an installer.
Cons: You can't edit any of the embedded resources without a recompilation of the application. You also can't store user settings for this same reason (though you could silently create a settings file in App_Data or similar).
Self extracting archive. This is the WinRAR method you mentioned in your question. You embed your application into a self-extracting archive which is set to extract to the users Temp directory or App_Data (or similar) and to launch your exe upon successful extraction.
Pros: You get the ability to update your resources as they aren't embedded into your actual application.
Cons: Technically, this is still an installer; albeit a very lightweight and self-contained one.
There are more, such as click-once; etc., but this explained the general idea.
Note: The correct .NET version will need to be installed for these to work as simply as I described.
Here are the concerns I can think of that an installer takes care of that you would need to worry about:
The correct .NET framework already exists.
Any assemblies that you reference from the GAC are already installed.
You don't need any custom registry entries or permissions to be granted.
Your app doesn't access anything that would keep it from working in a "low trust" environment when the user is not running as admin.
There are surely more, but basically if your app is self-contained and does not use any external resources and the correct .NET framework is installed, you should be able to just copy your build output and go.

How to create an executable to update a DLL in an installed application

I am looking at making an application more modular and accessing dlls so that I can change them if the client was wanting different functionality.
I know how to create the dlls and reference them, but I am trying to find a way to create an executable that will install a different version of a dll into the required application folder. I want to avoid having to put the new dlls into the original project and build a new install file and I want to keep things simple for the end user.
Currently I am using visual studio 2010
You could create MSI files for each of your dlls and use the standard installer process to update the dll. It is also possible to write an exe that downloads and extracts which will have an arbitrary amount of logic (licensing, download location now and then...).
A combnation of both might seem an interesting thing. A bootstrapper downloading msi files and silently installing them. You could have advanced features in the installer while having the freedom to decide what and when to install on your own.
Technical aspects popping into my mind: files in use may not be changed and if you change the interface theunchanges main program won't be able to use the new library.
It seems you're searching for a plugin architechtecture, you might want to look at MEF or Unity to perform the compositiom, but that is more a side comment.
There are few SO thread available on this great website. You should explorer them and try the best way to implement whatever situation you have..
Check these reference links:
from: Creating a patch to upgrade .NET application
If you already use a a VS Setup Project you can deploy the new version
of this project and it will upgrade existing installations. Have a
look at the setup and upgrade ids. The stop and start of the service
can be done by custom actions that can be defined in the project and
will be executed i.e. when your setup is committed or rollbacked etc.
Patch development in DotNet
How to make Patch-able/Update-able application?
create patch file using .net windows application
Note: Ref this For clickonce how to build a patch for existing installer

Installer for C# App

I'm developing an open source C# application. For awhile now, I've been using a basic .NET installer I coded myself. However, with a recent change, that is no longer practical for me, as I'd have to add a large number of files to the installer - and they may change with each release. A ZIP file is also not practical.
I've done some checking online, I see a lot of MSI, ClickOnce, Self-extracting ZIPs, and (imo the most promising) the NSIS system. None of them seem to exactly fit my needs, so I'm looking for advice on which system to use.
Actual installing of my program is very simple. Basically, I just need to copy the bin\Release directory (and all subdirs) to the client's computer. I've been achieving this somewhat ad-hoc, by embedding every file in my .NET installer, and maintaining a file table of what goes where.
Unfortunately, I just localized my app. I now have 30+ .resx files (Which are compiled to dlls and placed into MORE subdirectories by Visual Studio) and, obviously, it's impractical to add 30+ folders and DLLs to my installer. Hence why I'm on this search.
There's also a few other requirements:
The installer should search predefined directories for a specified .exe. (My app is designed to be a drop in replacement) If the .exe is not found, it should prompt for its location
The installer should verify that "OldApp.exe.bak" exists. If not, it should rename "OldApp.exe" to "OldApp.exe.bak"
The installer should update files. Ie, if "Culture.de.dll" hasn't changed, the installer will leave it alone.
The installer should work with all Windows versions of all .NET IDEs (VS, SharpDevelop, Mono, ect) but does not need to work on other platforms.
When I build the solution, the installer should be automatically regenerated. In other words, it should be run-able for by "Post-build" section.
The installer generation must be able to be added to a source code repo. This is so that anyone who downloads the source of my app can compile the installer as well.
Sorry for the long post, I figured it was better to post more than less.
I'd recommend SharpSetup. It combines WiX and C# for a pretty flexible implementation. Not much I've found it can't accomplish.
We use WIX extensively: http://wix.codeplex.com/
You may have to customize your installers with some exit routines to do things out of the ordinary, but there are hooks in Windows Installer framework that let you do that.
You can put these definition files (XML) in your source control, and you can configure a build to execute the installation. However, anyone that gets your source would need to have the WIX utilities installed.
I would recommend NSIS. From my experience any installer feature that I have required has been covered in NSIS documentation or community examples. I can't comment on NSIS integration with Visual Studio as I use NSIS integrated with my Jenkins build server. There appears to be a free Visual Studio Add-In called Visual & Installer which provides NSIS integration with Visual Studio. I have not personally used it but it appears to be currently actively developed so might be worth checking out.
WIX is a good one. According to Wikipedia, it is used by Microsoft to produce installers for some of their own products.

Deploying C# (.NET 2.0) application as a portable application?

Is it possible to deploy a .NET 2.0 application as a portable executable?
So that my program can be ran in a Flash Disk without the .NET Framework 2.0 installed in the target machine. Or maybe is it possible to distribute my program with the required .NET DLLs, so that no framework installation is necessary?
I know that there are some alternative tools to turn my .NET exe into a single native executable like RemoteSoft Salamander, Xenocode Postbuild, and Thinstall, but unfortunately I can't afford one.
I also tried to embed the dependencies with Mono's mkbundle, but it messed my program up =\ (no XP visual style, broke some controls and its functionality)
Any kind of help would be appreciated :)
Thanks.
fyi: my IDE is Microsoft Visual C# 2008 Express Edition with .NET Framework 2.0 as the target framework.
Well, other than things like Salamander and Thinstall (now VMWare ThinApp) you would have to have .NET installed if you really want to run .NET.
It may be possible to run Mono without actually installing it (not statically linking your program, but including Mono on the flash drive). I suspect it would be tricky though, as you'd have to tell the runtime about things like the GAC location.
I can't see anything in the Mono FAQ about this, but you might want to ping a Mono mailing list - it sounds like a potentially interesting and useful thing to be able to do.
No; you need either the framework installed, or the tools like you have mentioned.
You could potentially look at mono's new static linker, but that is about it...
I have not tried this myself but here's the procedure:
Make a C# project.
In Solution Explorer, inside your project, there is a line "Reference". Click the plus near it. Now you can see all the dependencies of your project. Delete all references that aren't used (delete, and try to run/build. If it is possible to do it, that it is unused. If there is an error, return it by adding it (right mouse click, "Add Reference")).
For each reference, go to Properties, and in the property "Copy Local" choose "True". For each Image, Icon... make like to the referenced.
Rebuild you project. Now in your Build/Release folder (inside bin) you will see many dll files. Those files have the information of every resource.
Copy all the files in the folder (from step number 4) into a new folder.
Go to the folder: "\Microsoft.Net\Framework\" and copy the file "mscrolib.dll" to the new folder from step 5. If you don't find this file, you can always make a search in the Hard Drive which contains Windows folder.
Now your app is portable (with the whole folder content).
-- Source: http://www.codeproject.com/Tips/392308/Csharp-Portable-Exe-File
Well Thinstall is very expensive and it doesn't work in all situations. If you want to run your app without .Net installed you might run into trouble although there are tools that do that Xenocode has a tool that can do this for you and it's cheaper than thinstall.
But if you ask my opinion it's a bad idea to use them. Better convince your target market to install .Net 2 (Which is pretty much universal these days), and then pack all of your library files into one file using a cheaper Obfuscator like tool (There's a good one from Smartassembly.)
I've used Thinstall for a long time, and I've worked on this technology a lot, so I am not shooting off without experience.

Categories

Resources