Visual Studio是否支持将MSBuild任务添加到项目中? [英] Does Visual Studio support adding MSBuild tasks to projects?

查看:93
本文介绍了Visual Studio是否支持将MSBuild任务添加到项目中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试向Visual Studio项目(VS 2012 Express)中添加一些简单的MSBuild任务-具体来说,是创建一个子目录,然后将一些文件复制到输出目录的子目录中,以进行打包.

I'm trying to add some simple MSBuild tasks to a Visual Studio project (VS 2012 Express) - specifically, to create a subdirectory then copy some files to a subdirectory of the output directory ready for packaging.

我看到VS支持自定义构建步骤,这是命令行调用.但是,由于VS是基于MSBuild的,因此应该可以将它们直接添加为 MSBuild任务(如复制任务) http://msdn.microsoft.com/zh-cn/library/ms366724.aspx"rel =" nofollow> AfterBuild预定义目标.

I see that VS supports custom build steps, which are command-line invocations. However, since VS is based on MSBuild it should be possible to add these directly as MSBuild tasks like the Copy Task in the AfterBuild pre-defined target.

我找不到在Visual Studio框架中实际添加此类任务的任何方法. 文档仅从MSBuild角度进行讨论,而不是在Visual Studio的UI中如何工作.那里似乎也没有讨论引用构建输出等的属性.大概是那些由msbuild自己使用的对象.

What I can't find is any way to actually add such tasks within the framework of Visual Studio. The documentation only talks about it from an MSBuild perspective, not how it works within Visual Studio's UI. It also doesn't seem to discuss the properties that refer to build output etc there; presumably they're just those used by msbuild its self.

在Visual Studio的UI中是否支持MSBuild任务管理,而它已从Express版本中消失了?还是我必须去破解项目文件XML以添加MSBuild任务?是否支持该功能以及应采用的方式?

Is there support for MSBuild task management in Visual Studio's UI and it's just crippled out of my Express edition? Or do I have to go hack the project file XML to add MSBuild tasks? Is that supported and the way it's supposed to be done?

我曾经使用过Eclipse和Ant或Maven,在IDE中支持所有这些功能,尽管您当然可以直接修改XML.在Visual Studio中根本找不到用于MSBuild任务管理的UI,这非常令人困惑.我会因为使用免费赠品版本而错过明显的内容吗?

I'm used to working with Eclipse and Ant or Maven, where all this is supported within the IDE, though of course you can hack the XML directly. Finding no UI at all for MSBuild task management in Visual Studio is quite confusing. Am I missing the obvious or crippled by using the freebie edition?

推荐答案

对于C ++项目,您可以使用属性

For C++ projects, you can use the property

<CppCleanDependsOn>DeleteOutputs;$(CppCleanDependsOn)</CppCleanDependsOn>

而不是像以前那样定义BeforeClean目标.

instead of defining the BeforeClean target like you did.

据我了解,应避免使用CallTarget.在您的示例中,应该使用DependsOnTargets来执行此操作,就像在MS提供的文件中的许多虚拟目标中所看到的那样.目标仅调用"其他目标的函数的类似机制是通过DependsOnTargets完成的.该流程与过程编程并不完全相同.

From what I read, CallTarget is to be avoided. In your example, you should use DependsOnTargets to do that, as you see in many dummy targets in the MS supplied files. The analogous mechanism of a function where a target just "calls" other targets is done with DependsOnTargets. The flow is not really the same as procedural programming.

Intellisense:我从不使用它.仅在props文件中有条件的AdditionalIncludeDirectories才是真的吗?如果您仅选择一种配置在IDE中编辑属性,请继续编辑IDE放置在proj文件中的条目.

Intellisense: I never use it. Is that true for conditional AdditionalIncludeDirectories in the props file only? Go ahead and edit the entry in the proj file where the IDE put it, if you edit the property in the IDE with just one configuration chosen.

这篇关于Visual Studio是否支持将MSBuild任务添加到项目中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆