Creating portable (non-installing) windows applica

2019-04-08 09:07发布

I have a .net 3.5 application and i'd like to make it portable. It's simple and runs perfectly, i've sent the .EXE + .DLL's to some friends and it works as intended when running the exe with the .DLL's and the .ICO (that i have used in it) along in the same folder.

What i want is simple: creating a single EXE file that cares the dll's, image and whatever-i-want along with it without being a setup, and requiring no installation. (a.k.a portable)

I may consider migrating it to .net 2.0 if needed, i don't use any 3.5-only functionality, in fact, i'm not really sure why i'm using 3.5 (i'm new at programming anyhow)

I'd like any tips, links, or an explanation on how to do it, because it's really annoying sending .rar's to my friends and telling them to extract and run the .exe among all "weird files" as they call (besides, not everyone has extension display in folders, so it's a nightmare)

(I have searched in StackOverflow, and haven't found any questions that answer what i'm asking, the only one that I found to be like it ended up in a discussion of framework availability in windows machines, language choosing and no good answers.)

3条回答
聊天终结者
2楼-- · 2019-04-08 09:25

You could also use Xenocode to Virtualize Your Applications. Specifically Xenocode Postbuild for .NET.

查看更多
迷人小祖宗
3楼-- · 2019-04-08 09:35

You can use ILMerge to merge all the assemblies into your executable. I'd expect your icon to already be an embedded resource - or you should at least be able to create it as such.

Targeting .NET 2.0 would make the application more widely portable in that it would just work on machines which only have .NET 2.0 installed - but I don't know what the proportions look like for 2.0 vs 3.5 deployment, and more importantly they may well not be the same as the proportions for deployment out of your target audience.

查看更多
地球回转人心会变
4楼-- · 2019-04-08 09:42

You can add any data (assemblies, icons, etc) required by your application as resources or embedded files.

Either use the resource editor, or if you want to get your hands dirtier, you can add any file by just right clicking on the project in the solution explorer and doing an "add existing item", getting properties on the file and setting Build Aciton to "Embedded Resource".

Resources like Icons can just be used directly - as in DrawIcon(Properties.Resources.MyIcon)

Data files can be loaded using Application.GetManifestResource (and related methods) to get a stream to load from. For example, for an assembly, you can use Assembly.Load() directly from the manifest resource stream for your resource.

查看更多
登录 后发表回答