MSBuild自定义任务"Hello World"演练 [英] MSBuild custom task "Hello World" walkthrough
问题描述
有人可以写(或链接到)一个演练来确切地解释 如何创建自定义MSBuild任务并在构建过程中运行它吗?我正在寻找一个从Microsoft.Build.Utilities.Task
继承并仅执行以下操作的自定义任务:
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 true;
}
(我已经工作了几个小时,并不断收到找不到[无论如何]任务.请检查以下内容"消息.我认为我必须在某个地方缺少必要的步骤.如果有一个清晰的教程,我可以跟进,也许我会找出我的不足之处.)
(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.)
推荐答案
您是否在MSBuild项目文件中声明自定义任务?您需要这样的一行:
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" />
然后MSBuild可以执行您的任务.
Then MSBuild can execute your task.
这篇关于MSBuild自定义任务"Hello World"演练的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!