Packaging a .NET Application So It Will Run On A Computer Without .NET
Asked Answered
K

3

8

I have been recently trying to deploy a C# application on a computer that does not have .NET installed.

I know that there have been many questions around the same topic here on StackOverflow. Here are a few of them, of which I read the responses to all:

Packaging up the .net framework with a .net application deployment

Run a .net application without installing .net client profile?

Run C# windows application in windows XP without installing .NET Framework

So all of the responses to the above questions state that it is impossible without specific software, etc. One software mentioned was the Salamander .NET Linker. The only problem with that is that I cannot seem to be able to run the application after it has been processed by Salamender. I understand that this in itself is impossible, as it requires the .NET virtual machine to run. However, in the past, I have made Java applications and along with them, I shipped the entire JVM. Surprisingly, they still worked. So the reason why this is not a duplicate of the above questions is because my true question is:

What items of the .NET framework would I need to package? If I do manage to package all, would placing them in the same directory as the application I'm running allow the application to run?

I found one solution to this, the Microsoft .NET Redist Package. The only problem with this is that it has a GUI of its own. Aside from that, it would be a perfect fit. So, could anyone tell me one of two things:

Is there a command-line .NET package, and if so, where do I download it?

If there isn't, or it would be impractical to do so, approximately what directories would I need to copy from the .NET installations?

I understand that these files and directories are system specific, and that my .NET installation may not work on your computer, but if C# is like Java, then this should be achievable. Is it? Size is not a limitation, it does not matter to me whether or not the application and all its files is 1GB, or if it is only 1MB.

If in case there is no other solution, I used Dependency Walker to check all the dependencies of my program. If I were to package most of them, would my application, in theory, work?

Kowal answered 6/4, 2012 at 22:56 Comment(1)
These static linkers are a terrible idea. Your application will not benefit from security fixes and other enhancements (ala Windows Update).Aquacade
K
12

For .NET, you really must just install the appropriate .NET framework. The .NET framework installation does include command line options to allow for silent installs, such as:

dotnetfx35.exe /q /norestart

For details on the command line options, see the options for 3.5 and for .NET 4.0.

That being said, most installation packages will handle these details for you as part of the installation. Using a decent installer will take care of this dependency automatically.

Karisa answered 6/4, 2012 at 23:5 Comment(3)
Is there any command to make it show how much it has installed, in a format like a percentage, or current file extracting... etc.? I checked the options for 3.5 link you posted, but did not find anything among those lines in there.Kowal
First you don't want a GUI and now you do?Aquacade
I do not want a GUI. And the files extracting is not a must, but I was wondering if there was a command-line style percentage or extractor, something like, say wget. I'm not sure if that counts as a GUI. If it does, sorry I raised confusion.Kowal
P
8

Depending on the pieces of the .NET Framework you need, you can use Mono. It supports shipping the runtime without installing just like you would a JVM, or you can statically link against the binaries to create a native executable .

Pemba answered 6/4, 2012 at 23:9 Comment(0)
R
2

If you are planning to deploy your application (and presuming the setup process doesn't need to be too complex), you can simply create a Setup project in Visual Studio and then bootstrap the prerequisites (.NET framework, and other stuff you think you might need).

You can follow the steps described in these MSDN articles:

A walkthrough is given in this CodeProject article.

For more complex deployment scenarios (such as installing device drivers along your app, or better localization support), I would recommend looking into WiX (Windows Installer XML) toolset. It's a toolset that builds Windows installation packages, which you configure using XML files inside Visual Studio. WiX also supports various bootstrapping scenarios.

This page covers the differences between VS Setup projects, WiX, and InstallShield.

Roccoroch answered 6/4, 2012 at 23:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.