NuGet ecosystem already overgrew the original idea of the NuGet as a design-time package management tool. NuGet powers installers, helps to create auto-updateable applications and pluggable solutions. What the ecosystem missed so far, is the general-purpose library which abstracts complex, not yet documented NuGet API and simplifies the NuGet-based solutions development.
Welcome Dropcraft. Based on the version 4 of NuGet, it provides a high-level package management API and enables various scenarios of using NuGet packages in the applications. Going beyond just package installations, updates and uninstallations, Dropcraft includes a runtime API for the installed packages discovering and a simple extensibility framework, which is based on NuGet packages.
The main features of Dropcraft
- Packages installation (update, uninstallation) from the local and remote sources to any target folder.
- Package management API and a reference implementation of the command line tool.
- Configurable package resolution and deployment strategies.
- Runtime API which allows to discover installed packages, package dependencies and initialize the packages.
- Package-based application extensibility model (i.e. NuGet packages as plugins). Runtime application composition.
- Framework extensibility via the deployment and runtime hooks. Packages are able to expose event handlers to track all Dropcraft activities and modify the hosting application behavior.
Scenarios, where Dropcraft may be useful
- Deployment and management of individual NuGet packages in test environment and in production.
- An internal tool packaging using NuGet packages and deployment to target PCs.
- A custom installer which build the final product directly from NuGet packages.
- NuGet package-based plugin infrastructure.
Get started
The easiest way to try Dropcraft is to use dropcraft.exe command line tool. It is built using public Dropcraft APIs and can be used as a framework usage example by itself.
dropcraft.exe install "bootstrap/3.0.0" --path "c:\DemoApp" -s "https://api.nuget.org/v3/index.json" --framework net461
This command instructs Dropcraft to install bootstrap v3.0.0 package from NuGet.org to c:\DemoApp\ folder. It automatically resolves all the dependencies, downloads the packages and installs them
Installing packages... 0 product package(s) found and 1 new package(s) requested Versions are confirmed 2 package(s) are resolved 2 package(s) to install 0 package(s) to update bootstrap/3.0.0 downloaded jQuery/1.9.0 downloaded bootstrap/3.0.0 installed jQuery/1.9.0 installed Installation complete.
As the result, C:\DemoApp contains Content, Scripts and fonts folder from the bootstrap and jQuery packages. Dropcraft followed the instructions and installed Bootstrap 3.0.0, which is pretty old. So, the following command will update it
dropcraft.exe install "bootstrap" --path "c:\DemoApp" -s "https://api.nuget.org/v3/index.json" --framework net461
Installing packages... 2 product package(s) found and 1 new package(s) requested Versions are confirmed 2 package(s) are resolved 0 package(s) to install 2 package(s) to update bootstrap/3.3.7 downloaded jQuery/1.9.1 downloaded bootstrap/3.0.0 uninstalled jQuery/1.9.0 uninstalled bootstrap/3.3.7 installed jQuery/1.9.1 installed Installation complete.
Dropcraft automatically resolved the latest version for the packages and upgraded them. Similarly, Dropcraft can install additional packages, downgrade or uninstall exiting ones.
Advanced scenarios
Previous example demonstrated used of the unmodified NuGet packages with Dropcraft. To enable more advanced scenarios, Dropcraft introduces an additional package manifest file, which can be included in the package by its author.
Package manifest allows to notify Dropcaft about package’s initialization method, allows packages to intercept various Dropcraft events and participate in the application composition.
Dropcraft defines a lightweight application composition model based on an extensibility point concept. Any package is able to define one or many extensibility points which will be linked with the corresponding extensions exported by other packages. It allows to create a chain of extensibility points/extensions and build application from packages like from the Lego blocks.
Dropcraft WPF demo app demonstrates this concept. It consists from the several NuGet package which can be installed separately or all together. First command installs a package with the common interfaces, an executable and the application’s main window. It uses two package sources – NuGet.org and MyGet.org
dropcraft.exe install "Dropcraft.WpfExample.App" "Dropcraft.WpfExample.Shell" "Dropcraft.WpfExample.Common" --path "c:\DemoWPF" -s "https://www.myget.org/F/dropcraft/api/v3/index.json" -s "https://api.nuget.org/v3/index.json" --framework net461
The resulting application is just an empty window. Next command adds some functionality by installing an extension – text editor.
dropcraft.exe install "Dropcraft.WpfExample.Editor" --path "c:\DemoWPF" -s "https://www.myget.org/F/dropcraft/api/v3/index.json" -s "https://api.nuget.org/v3/index.json" --framework net461
Text editor defines a new extensibility point – editor command – and there is Dropcraft.WpfExample.Commands package which exports two command. So the next step is to install it
dropcraft.exe install "Dropcraft.WpfExample.Commands" --path "c:\DemoWPF" -s "https://www.myget.org/F/dropcraft/api/v3/index.json" -s "https://api.nuget.org/v3/index.json" --framework net461
The final result is the application composed from the packages where all the packages are loosely coupled through the interfaces and the composition is facilitated by Dropcraft. The framework takes care about the order of the packages initialization, runtime extensions registration and other scenarios common in the pluggable applications.
Conclusion
- GitHub repository: https://github.com/Dropcraft/Dropcraft
- NuGet packages: NuGet.org
Dropcraft provides APIs which can be used by applications to incorporate NuGet functionality. It enables a wide range of scenarios, from direct manipulation with NuGet packages, to package-based plugins and runtime application composition.
While the release 0.2.1 is compiled for .NET 4.6.1, Dropcraft libraries target .NET Standard and are going to support .NET Core in the future releases. Similarly, future release will support ASP.NET Core in addition to the desktop applications.
blog comments powered by Disqus