Skip to content

AppBundle is a .NET library that can add resources to your application after its compilation

Notifications You must be signed in to change notification settings

Wertzui123/AppBundle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AppBundle

AppBundle is a .NET library that can add resources to your application after its compilation.

Installing...

...the bundle generator

... as a library

  1. Download the AppBundle.dll here
  2. Add the DLL to your application
  3. 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();

... as a standalone application

Windows

  1. Download the AppBundle.exe here
  2. Place it where you need it
  3. Run a command similar to this:
    AppBundle.exe program.exe example="Hello World!"
    

Linux

  1. Download the AppBundle executable here
  2. Place it where you need it
  3. Run a command similar to this:
    ./AppBundle program example="Hello World!"
    

... the bundle loader

  1. Download the AppBundleLoader.dll here
  2. Add the dll your application
  3. Call AppBundle.Loader.Main() at the start of your main method
  4. 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):
    public static void Main()
    {
        AppBundle.Loader.Main();
        // Your code
    }
    becomes
    public static void Main()
    {
        AppBundle.Loader.Main();
        Init();
    }
    
    private static void Init()
    {
        // Your code
    }
  5. 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.

Limitations

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:
    public static void Main()
    {
        AppBundle.Loader.Main();
        Init();
    }
    becomes
    public static void Main()
    {
        InitLoader();
        Init();
    }
    
    private static void InitLoader()
    {
        AppBundle.Loader.Main();
    }
    
    private static void Init()
    {
        // Your code
    }

About

AppBundle is a .NET library that can add resources to your application after its compilation

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages