AppBundle is a .NET library that can add resources to your application after its compilation.
- Download the AppBundle.dll here
- Add the DLL to your application
- Use a code snippet similar to this to generate a bundle:
var bundle = new AppBundle("App.exe"); bundle.AddResource("ExampleString", "Hello World!"); bundle.AddResource("Bytes", new byte[] { (byte)42, (byte)24 }); bundle.AddResource("BasicAssembly", assembly) bundle.Generate();
- Download the AppBundle.exe here
- Place it where you need it
- Run a command similar to this:
AppBundle.exe program.exe example="Hello World!"
- Download the AppBundle executable here
- Place it where you need it
- Run a command similar to this:
./AppBundle program example="Hello World!"
- Download the AppBundleLoader.dll here
- Add the dll your application
- Call
AppBundle.Loader.Main()
at the start of your main method - Move all code (except the code from step 3) in your main method to a new method and call that method from your main method (this is only needed if you bundle DLLs into your app):
becomes
public static void Main() { AppBundle.Loader.Main(); // Your code }
public static void Main() { AppBundle.Loader.Main(); Init(); } private static void Init() { // Your code }
- Use a code snippet similar to this to get the resources in your bundle:
var resources = AppBundle.Loader.GetResources();
The GetResources method returns a Dictionary<string, object> with the name of a resource as the key and the resource as the value.
AppBundle does not work with files generated by mkbundle with the --simple option!
You also cannot bundle the bundle loader into your application using AppBundle to create a self-contained application.
This can be achieved by either using mkbundle or by:
- Adding the AppBundleLoader.dll as a resource file
- Pasting a code snippet similar to this in your main method:
AppDomain.CurrentDomain.AssemblyResolve += (_, a) => { var assemblyName = new AssemblyName(a.Name).Name; return assemblyName == "AppBundleLoader" ? Assembly.Load(Resources.AppBundleLoader) : null; };
- Moving
AppBundle.Loader.Main()
to its own method and calling that method after step 2:becomespublic static void Main() { AppBundle.Loader.Main(); Init(); }
public static void Main() { InitLoader(); Init(); } private static void InitLoader() { AppBundle.Loader.Main(); } private static void Init() { // Your code }