在MSBUILD中,如何指定检查命令行或VS是否启动它的条件? [英] In MSBUILD, how can you specify a condition that check whether command line or VS launched it?

查看:80
本文介绍了在MSBUILD中,如何指定检查命令行或VS是否启动它的条件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个csproj,只有在目标是从Visual Studio内而不是从MSBUILD命令行执行的情况下,才希望在Visual Studio中触发特定文件的打开.我该怎么做?

I have a csproj that I would like to have trigger the opening of a particular file in Visual Studio, only if the target was executed from within Visual Studio, but not from the MSBUILD command line. How do I do this?

推荐答案

在Visual Studio中构建时,属性$(BuildingInsideVisualStudio)设置为true.可以在您的项目或.targets文件中使用它,以使生成的行为有所不同.

When building inside Visual Studio, the property $(BuildingInsideVisualStudio) is set to true. This can be used in your project or .targets files to cause the build to behave differently.

在.* proj或.targets文件中如何使用它的示例:

Example how it could be used in your .*proj or .targets file:

<PropertyGroup>
  <MyProperty Condition="'$(BuildingInsideVisualStudio)' == 'true'">This build is done by VS</MyProperty>
  <MyProperty Condition="'$(BuildingInsideVisualStudio)' != 'true'">This build is done from command line of by TFS</MyProperty>
</PropertyGroup>

这篇关于在MSBUILD中,如何指定检查命令行或VS是否启动它的条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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