Visual Studio中是否有任何UI工具可以编辑MSBuild条件构造? [英] Is there any UI tool within Visual Studio can edit MSBuild conditional constructs?

查看:54
本文介绍了Visual Studio中是否有任何UI工具可以编辑MSBuild条件构造?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用文本编辑工具(notepad ++)编辑".prop"或".vcxproj",只是因为我想使用MSBuild条件构造,而无法在Visual Studio中找到UI工具来执行此操作.有谁知道我可以在哪里编辑,以便生成XML语句,例如以下条件语句?

I am using text edit tools (notepad++) to edit ".prop" or ".vcxproj" just because I want to use MSBuild conditional constructs whereas cannot find a UI tool within Visual Studio to do this. Is there anyone knows where I can edit so that generating XML statement like following conditional statement?

<ItemDefinitionGroup Condition="$(Configuration.StartsWith('MyProject-'))">

推荐答案

到目前为止,恐怕还没有UI工具可以生成XML语句 就像上面的声明:

So far, I’m afraid there has no UI tool can generate XML statement like the statement above:

1.在VS IDE中,对于某些元素,例如<PreBuildEvent>:Right-click Project=> Properties=> write a command in build events(Pre-build event),则VS将生成XML语句,例如<PostBuildEvent>…</PostBuildEvent>.

1.In VS IDE, for some Elements like <PreBuildEvent>: Right-click Project=> Properties=> write a command in build events(Pre-build event), then VS will generate an XML statement like "<PostBuildEvent>…</PostBuildEvent>".

2.对于vcxproj文件,如果我们为此项目创建新配置,则IDE将在.proj文件中为我们生成类似<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='TestConfiguration|Win32'">的语句.

2.And as for vcxproj file, if we create a new configuration for this project, then the IDE will generate a statement like <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='TestConfiguration|Win32'"> in .proj file for us.

3.但是对于您上面提到的语句,该语句包含

3.But for the statement you mentioned above, which contains a Property Function (Configuration.StartWith) , currently there seems no valid way to generate it In VS unless we hand-edit it by .proj file. Because the Configuration.StartsWith('…')) is a custom statement so no UI-combination In VS can generate such statement(with function) in .proj file. Sorry for this inconvenience.

此外:

1.通常,我们可以通过Right-click Project=>Unload Poeject=>Edit xx.xxproj file在VS ide中编辑.proj文件. vs中的编辑器将帮助检查我们在proj文件中键入的元素是否正确,我认为它可能更适合手动编辑.之后,Right-Click Project and choose Reload加载文件.

1.Usually, we can edit the .proj file within VS ide by Right-click Project=>Unload Poeject=>Edit xx.xxproj file. The editor in vs will help check if elements we type in proj file are correct, I think it may be more suitable for hand-editing. After that, Right-Click Project and choose Reload to get files loaded.

2.对于.props文件,我们也可以通过File=>opendrag it into VS window在vs中打开和编辑该文件.

2.For .props file, also we can open and edit it in vs by File=>open or just drag it into VS window.

3.关于Configuration.StartWith(),如果我们有一个名为"MyProject-"的自定义配置,则返回值为true,否则返回false.因此,如果要通过projectName设置条件,则ProjectName.StartsWith()可能更合适. 希望以上所有对您有所帮助.期待您的回复.

3.And about Configuration.StartWith(), if we have a customed Configuration named "MyProject-", then the return value is true, otherwise, it would be false. So if what you want is to set the condition by projectName, maybe ProjectName.StartsWith() can be more suitable. Hope all above helps. Look forward to your reply.

这篇关于Visual Studio中是否有任何UI工具可以编辑MSBuild条件构造?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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