MinimalHMGenerator 0.1.0
dotnet tool install --global MinimalHMGenerator --version 0.1.0
dotnet new tool-manifest
dotnet tool install --local MinimalHMGenerator --version 0.1.0
#tool dotnet:?package=MinimalHMGenerator&version=0.1.0
nuke :add-package MinimalHMGenerator --version 0.1.0
Dotnet Minimal Hosting Model Generator
Description
DotnetMinimalHostingModelGenerator
is a command-line tool designed to help developers transition their ASP.NET Core applications to the modern minimal hosting model. This tool reads a traditional Startup.cs
file and generates a new Program.cs
file that adheres to the minimal hosting model introduced in .NET 6 and later.
Features
- Transform
Startup.cs
: Converts the contents of a traditionalStartup.cs
file to a minimal hosting model format. - Customizable Output: Allows specifying the directory where the new
Program.cs
file will be saved. - Validation: Ensures the specified
Startup.cs
file and output directory exist before proceeding.
Installation
Clone the Repository
git clone <repository-url> cd DotnetMinimalHostingModelGenerator
Build the Tool
dotnet build
Install as a Global Tool (Optional)
dotnet pack dotnet tool install --global --add-source ./nupkg DotnetMinimalHostingModelGenerator
Or launch the script "tool_install.sh" available in the folder.
Usage
Open a terminal.
Run the tool with the following syntax (if installed globally):
minimal-hm-generator transform --startup-file <path-to-Startup.cs> --output-file-path <output-directory>
Example:
minimal-hm-generator transform --startup-file ./Startup.cs --output-file-path ./Output/
Options
Option | Description | Example |
---|---|---|
--startup-file |
The path to the Startup.cs file to transform. |
--startup-file ./Startup.cs |
--output-file-path |
The directory where Program.cs will be saved. |
--output-file-path ./Output/ |
Validation Rules
- The specified
Startup.cs
file must exist. Otherwise, an error will be shown:Startup file './Startup.cs' does not exist.
- The specified output directory must exist. Otherwise, an error will be shown:
Output file path './Output/' does not exist.
Example Output
Running the tool successfully will output a message like:
Successfully transformed ./Startup.cs
The new Program.cs
file will be located in the specified output directory.
Exit Codes
- 0: Successful operation.
- 1: Errors during validation or transformation.
Contributing
Contributions are welcome! Please submit issues or pull requests to improve the tool.
License
This tool is open source and distributed under the MIT License. See the LICENSE
file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
This package has no dependencies.
Version | Downloads | Last updated |
---|---|---|
0.1.0 | 119 | 4 months ago |