dotnet-msbuild-tasks
БесплатноБез исполняемых скриптовНе проверенWriting custom MSBuild tasks. ITask, ToolTask, IIncrementalTask, inline tasks, UsingTask.
от wshaddix★ 94 звезды на GitHubОб этом скилле
dotnet-msbuild-tasks
Guidance for authoring custom MSBuild tasks: implementing the ITask interface, extending ToolTask for CLI wrappers, using IIncrementalTask (MSBuild 17.8+) for incremental execution, defining inline tasks with CodeTaskFactory, registering tasks via UsingTask, declaring task parameters, debugging tasks, and packaging tasks as NuGet packages.
Version assumptions: .NET 8.0+ SDK (MSBuild 17.8+). IIncrementalTask requires MSBuild 17.8+ (VS 2022 17.8+, .NET 8 SDK). All examples use SDK-style projects. All C# examples assume using Microsoft.Build.Framework; and using Microsoft.Build.Utilities; are in scope unless shown explicitly.
Scope boundary: This skill owns custom MSBuild task authoring -- ITask, ToolTask, IIncrementalTask, inline tasks, UsingTask, parameters, debugging, and NuGet packaging. MSBuild project system authoring (targets, props, items, conditions) is owned by [skill:dotnet-msbuild-authoring].
Cross-references: [skill:dotnet-msbuild-authoring] for custom targets, import ordering, items, conditions, and property functions.
ITask Interface
All MSBuild tasks implement Microsoft.Build.Framework.ITask. The simplest approach is to inherit from Microsoft.Build.Utilities.Task, which provides default implementations for BuildEngine and HostObject.
Minimal Custom Task
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
public class GenerateFileHash : Task
{
[Required]
public string InputFile { get; set; } = string.Empty;
[Output]
public string Hash { get; set; } = string.Empty;
public override bool Execute()
{
if (!File.Exists(InputFile))
{
Log.LogError("Input file not found: {0}", InputFile);
return false;
}
using var stream = File.OpenRead(InputFile);
var bytes = System.Security.Cryptography.SHA256.HashData(stream);
Hash = Convert.ToHexString(bytes).ToLowerInvariant();
Log.LogMessage(MessageImportance.Normal,
"SHA-256 hash for {0}: {1}", InputFile, Hash);
return true;
}
}
ITask Contract
| Member | Purpose |
|---|---|
BuildEngine |
Provides logging, error reporting, and build context |
HostObject |
Host-specific data (rarely used) |
Execute() |
Runs the task. Return true for success, false for failure |
The Task base class exposes a Log property (TaskLoggingHelper) with convenience methods:
| Method | When to use |
|---|---|
Log.LogMessage(importance, msg) |
Informational output (Normal, High, Low) |
Log.LogWarning(msg) |
Non-fatal issues |
Log.LogError(msg) |
Fatal errors (causes build failure) |
Log.LogWarningFromException(ex) |
Warning from caught exception |
Log.LogErrorFromException(ex) |
Error from caught exception |
ToolTask Base Class
ToolTask extends Task for wrapping external command-line tools. It handles process invocation, output capture, and exit code interpretation.
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
public class RunLintTool : ToolTask
{
[Required]
public string SourceDirectory { get; set; } = string.Empty;
public string Severity { get; set; } = "warning";
// Required: name of the executable
protected override string ToolName => "dotnet-lint";
// Required: full path or tool name (OS resolves via PATH)
protected override string GenerateFullPathToTool()
{
// Return tool name; the OS resolves it via PATH at process start
return ToolName;
}
// Required: build the command-line arguments
protected override string GenerateCommandLineCommands()
{
var builder = new CommandLineBuilder();
builder.AppendSwitch("--check");
builder.AppendSwitchIfNotNull("--severity ", Severity);
builder.AppendFileNameIfNotNull(SourceDirectory);
return builder.ToString();
}
// Optional: interpret non-zero exit codes
protected override bool HandleTaskExecutionErrors()
{
Log.LogError("{0} found lint violations in {1}",
ToolName, SourceDirectory);
return false;
}
}
Key ToolTask Overrides
| Override | Purpose |
|---|---|
ToolName |
Executable file name (e.g., dotnet-lint) |
GenerateFullPathToTool() |
Full path to executable, or return ToolName to let the OS resolve via PATH |
GenerateCommandLineCommands() |
Build argument string for the tool |
GenerateResponseFileCommands() |
Arguments written to a response file (for long command lines) |
HandleTaskExecutionErrors() |
Custom handling of non-zero exit codes |
StandardOutputLoggingImportance |
Log level for stdout (default: Low) |
StandardErrorLoggingImportance |
Log level for stderr (default: Normal) |
Response Files for Long Command Lines
When the argument list is too long for the OS command line (common with many source files), use `G
Установить dotnet-msbuild-tasks в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл dotnet-msbuild-tasks?
Writing custom MSBuild tasks. ITask, ToolTask, IIncrementalTask, inline tasks, UsingTask.
Как установить скилл dotnet-msbuild-tasks?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл dotnet-msbuild-tasks запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic