CSharpTask 2.0.0

dotnet add package CSharpTask --version 2.0.0
NuGet\Install-Package CSharpTask -Version 2.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CSharpTask" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CSharpTask --version 2.0.0
#r "nuget: CSharpTask, 2.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CSharpTask as a Cake Addin
#addin nuget:?package=CSharpTask&version=2.0.0

// Install CSharpTask as a Cake Tool
#tool nuget:?package=CSharpTask&version=2.0.0

CSharpTask

Microframework with provides tasks functionality into C# console application similar to rake in Ruby

Package

Package link: https://www.nuget.org/packages/CSharpTask/1.0.0

How to implement new task

Check CSharpTask.ExampleApp/Tasks/Dummy task example

  1. Implement 3 classes inside {RootNamespace}.{TaskName} namespace:
    • {TaskName}Task - with task implementation
    • {TaskName}Options - for task configuration
    • {TaskName}Startup - to register the task with its dependencies
  2. Provide TaskDescriptionAttribute with values for {TaskName}Task class

How to run task

Check CSharpTask.ExampleApp/Program.cs for the example setup.

  1. Register the task in your application using the TaskExtensions.UseStartup with task name provided from application arguments
  2. Validate task name from arguments with TaskExtension.ValidateRequestedTask method.
  3. Run application with task name as an argument to execute task
  4. Run application without a ny arguments to display all implemented tasks

Example output from the CSharpTask.ExampleApp

dotnet run --project CSharpTask.ExampleApp/CSharpTask.ExampleApp.csproj

Dummy: this is an example of task description
dotnet run --project CSharpTask.ExampleApp/CSharpTask.ExampleApp.csproj -- Dummy

DummyTask.ExecuteAsync Test Setting

Entity Framework Note!

EF uses own head-of-control while run command line tools (eg. ef migrate), it injects own entry point changing result of Assembly.GetEntryAssembly() method as side effect. It will lead to InvalidOperationException with message: Cannot find <task name> in <EF assembly>.

Use IHostBuilder UseStartup(this IHostBuilder hostBuilder, string taskName, Assembly? asm) with typeof(Program).Assembly provided into Assembly? asm argument to mitigate this error.

  if (!string.IsNullOrWhiteSpace(taskName))
  {
    hostBuilder.UseStartup(taskName, typeof(Program).Assembly);
  }
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0 158 1/8/2024
1.0.0 136 5/29/2023

Add support for .net8; Add possibility to override task's assembly