开发者

MSBuild custom task "Hello World" walkthrough

开发者 https://www.devze.com 2023-02-14 14:57 出处:网络
Can someone write (or link to) a walkthrough that explains exactly how to create a custom MSBuild task and run it during a build?I\'m looking for a custom task that inherits from Microsoft.Build.Utili

Can someone write (or link to) a walkthrough that explains exactly how to create a custom MSBuild task and run it during a build? I'm looking for a custom task that inherits from Microsoft.Build.Utilities.Task and does only this:

public override bool Execute()
{
    Log.LogMessage("Hello world!");
    return tru开发者_开发问答e;
}

(I've been working on this for hours and keep getting the "The [whatever] task was not found. Check the following" message. I think I must be missing an essential step somewhere. If there's a clear tutorial I can follow, perhaps I'll figure out where I'm falling short.)


Are you declaring your custom task in your MSBuild project file? You need a line like this:

    <UsingTask AssemblyFile="C:\PathTo\MyTasks.dll" TaskName="MyTasks.HelloWord" />

Then MSBuild can execute your task.


See

  1. Best Practices For Creating Reliable Builds section Creating Custom Tasks.
  2. THE CUSTOM MSBUILD TASK COOKBOOK from Bart De Smet
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号