https://github.com/wertzui123/appbundle
AppBundle is a .NET library that can add resources to your application after its compilation
https://github.com/wertzui123/appbundle
app appbundle bundle compilation csharp net
Last synced: 12 months ago
JSON representation
AppBundle is a .NET library that can add resources to your application after its compilation
- Host: GitHub
- URL: https://github.com/wertzui123/appbundle
- Owner: Wertzui123
- Created: 2021-01-26T19:01:54.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-07-27T18:59:46.000Z (over 4 years ago)
- Last Synced: 2025-01-01T19:12:55.416Z (about 1 year ago)
- Topics: app, appbundle, bundle, compilation, csharp, net
- Language: C#
- Homepage:
- Size: 2.97 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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:
```cs
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):
```cs
public static void Main()
{
AppBundle.Loader.Main();
// Your code
}
```
becomes
```cs
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:
```cs
var resources = AppBundle.Loader.GetResources();
```
The GetResources method returns a Dictionary 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:
```cs
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:
```cs
public static void Main()
{
AppBundle.Loader.Main();
Init();
}
```
becomes
```cs
public static void Main()
{
InitLoader();
Init();
}
private static void InitLoader()
{
AppBundle.Loader.Main();
}
private static void Init()
{
// Your code
}
```