English 中文(简体)
VS console app - compile all libraries into an exe
原标题:

I ve created a basic console app in Visual Studio 2008, which references an external assembly.

When I publish and install the project, both the executable and the external assembly are installed in the target folder.

Is it possible to compile the project, and have all referenced assemblies included in the main executable - so there is only one file to distribute?

Thanks for any help,

Franko

最佳回答

You can use ILMerge to merge the assemblies for deployment. This lets you keep them separate during development, but put them all into one .exe file when you ship.

问题回答

You can use ILMerge from Microsoft for this, or the Cecil tool from the Mono project.

You can create a setup file. so you can redistribute only one file. But it still going to be installed into a folder with each assembly separated.

You can also consider placing your assemblies into the GAC.

If you find ILMerge is not enough because your app needs files other than .net assemblies, I have found that packaging it as self extracting exe using MakeSFX works nicely. It sounds unlikely but with correct command line flags the self extracting bit is completely transparent and it runs just like any other application.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签