Nuget Package:

PM> Install-Package HBD.App.Shell

HBD.App.Shell

This post, I Will share the other Workspace source code for Console Shell application as well. This one will provides the core foundation for the console application. That allows building a loosely coupled, module-able and maintainable application.

How does it work?

This Shell application had been developed based on HBD.Mef library that will automatic load all modules in the defined folder at run time. This application is suitable for those who want to develop a batch job that will be triggered by the scheduler and execute the particular plugin based on the input parameters.

Quick Start

1. Add New Module

  • Open Visual Studio and create a new Class Library project example project name is Job.Module.
  • Install the latest version of HBD.App.Shell from Nuget.
  • Add a new class named Job1 and inherited from HBD.Mef.ConsoleApp.ConsoleModuleBase and then implement 2 abstract methods (Initialize and Run(params string[] args)) as below. Remember to add the ModuleExport attribute into your Job1 class.

The function of this job is writing a message to the console and log file.

2. Setup Publish Shell folder.

  • Copy folder [Solution Directory]\packages\HBD.App.Shell\tools\App.Shell to [Solution Directory]\Publish\App.Shell

3. Update project’s properties.

  • Right click on the project select Properties
  • Add below code into Post-build event
  • Set Start external program under Debug to Publish\App.Shell\HBD.App.Shell.exe
  • And set Working directory to Publish\App.Shell folder.
  • And then set the Command line arguments is -job1 param1 param2 param3.

Job Module Debug

  1. Add Module config and Debug your module.
  • Add a new Module_Job_Demo.json file with the following content.
  • Set Build action of this config file as below

Job Module Json

  • Run your module, the Shell application will display as below.

App Shell Job1

How to run multi jobs with parameters

As the Command line arguments above you will see the first parameter is the JobName and then follow by the parameters for that job. If you want to execute multi-job you can pass the Command-line arguments following this format: -JobName1 param1 param2 param3 -JobName2 param1 param2 param3

This is a screenshot when executing multi jobs. App Shell Job1 Job2

If the Environment is Debug the console window will keep open unstil you press a enter key.

Source code

You can download the Job.Module source code here in Github – Job.Module

And the source code of HBD.App.Shell in here Github – HBD.App.Shell

Hope, this Shell will help you to develop a plugin-able application faster and easier. Your feedback and ideas are much appreciated. Please feel free to drop me an email with your opinion.

Leave a Reply

Your email address will not be published. Required fields are marked *