0

I've got a question regarding .NET applications and the executable that is made with the release of the application. Right now I've made my application, and it's working as intended, and I know that in the Release folder you have to final application. It works, you can run it, but my problem is in distribution.

There are a lot of extra files generated by it, and probably because of that's what it needs to get running. But is there a possibility that I can wrap everything in a package so that I can distribute one file of ~2-3mb instead of a zip file containing every file individually.

I don't want to use a setup for my applicaton, because it's very small and a standalone application is better for me. Thanks in advance!

EDIT: It's for the most part DLL and XML files, see this image: https://i.stack.imgur.com/UnqeT.jpg

Kuubs
  • 1,300
  • 1
  • 14
  • 42

3 Answers3

3

You could use ILmerge. Its a nuget package from here https://www.nuget.org/packages/ilmerge. It can combine all the libraries and *.exe into one assembly. It is reliable and you can add it as part of your build events. Specifically as a Post Build Event when in release mode.

rasharasha
  • 301
  • 3
  • 9
1

I highly recommend to use Costura.Fody - by far the best and easiest way to embed resources in your assembly. It's available as NuGet package.

Install-Package Costura.Fody
Joakim Carlsson
  • 1,540
  • 5
  • 19
  • 42
0

This what I use personally for additional application files (i.e. database scripts, images, dictionaries or whatever arbitrary data files). I did not try this approach with assemblies though.

If you do not want to use setup, an option is to embed external files as executable application resources and extract them to application or temporary directory upon first run.

  • add resource file (i.e. Files.resx) to your project
  • in Visual Studio resource editor use option "Add Existing File"
  • label the resource (i.e. myResourceLabel); make sure Visual Studio treats it as "FILE" resource and not i.e. "IMAGE" (it is enough to use extension ".dat" as file extension)
  • from code point of view such "FILE" resource is seen as array of bytes, so you can easily extract resource data into file, i.e.:

.

if (!System.IO.File.Exists("myfile.dat"))
  System.IO.File.WriteAllBytes("myfile.dat", Files.myResourceLabel);
Kuba Wyrostek
  • 6,163
  • 1
  • 22
  • 40