是否可以在VS IDE中进行构建时进行检测? [英] Is it possible to detect when building in the VS IDE?

查看:70
本文介绍了是否可以在VS IDE中进行构建时进行检测?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在构建步骤之后,我添加了一个附加步骤,以便可以将mspec与teamcity集成.但是,在IDE中进行构建时,我不想运行它,因为它会延长构建时间.有什么办法可以检测到我是否正在从IDE中构建并且不执行此特定目标?这就是我到目前为止所拥有的.

I've added an additional after build step so that I can integrate mspec with teamcity. However I do not want to run this when I'm building in the IDE as it lengthens the time to build. Is there someway I can detect whether I'm building from the IDE and not execute this specific target? This is what I have so far.

<Target Name="RunSpecs">
    <PropertyGroup>
        <AdditionalSettings>--teamcity</AdditionalSettings>
        <MSpecCommand>..\Lib\mspec\mspec.exe $(AdditionalSettings) "$(TargetDir)$(AssemblyName).dll"</MSpecCommand>
    </PropertyGroup>
    <Message Importance="high" Text="Running Specs with this command: $(MSpecCommand)" />
    <Exec Command="$(MSpecCommand)" IgnoreExitCode="true" />
</Target>
<Target Name="AfterBuild" DependsOnTargets="RunSpecs" />

简单的解决方案是添加另一个构建配置,但我不想这样做.

The easy solution is to add another build configuration but I'd prefer not to do that.

转载到输出窗口的TeamCity输出也很烦人. :)

Also the TeamCity output being dumped to the output window is sort of annoying. :)

推荐答案

是的,您可以检查属性BuildingInsideVisualStudio.

Yes you can check the property BuildingInsideVisualStudio.

因此,您可以执行以下操作:

So in your case you could do something like the following:

<Target Name="RunSpecs" Condition=" '$(BuildingInsideVisualStudio)'!='true' ">
    <PropertyGroup>
        <AdditionalSettings>--teamcity</AdditionalSettings>
        <MSpecCommand>..\Lib\mspec\mspec.exe $(AdditionalSettings) "$(TargetDir)$(AssemblyName).dll"</MSpecCommand>
    </PropertyGroup>
    <Message Importance="high" Text="Running Specs with this command: $(MSpecCommand)" />
    <Exec Command="$(MSpecCommand)" IgnoreExitCode="true" />
</Target>

注意目标上的状况.仅供参考,通常我通常建议不要对目标施加条件,但这是一个很好的用法为他们.

Notice the condition on the target. FYI, generally I generally advise against putting condition on targets but this is a good usage for them.

这篇关于是否可以在VS IDE中进行构建时进行检测?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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