2010-02-22 53 views
9

我已經添加了一個額外的構建步驟,以便我可以將mspec與teamcity集成。但是,當我在IDE中構建時,我不想運行它,因爲它延長了構建時間。是否有某種方式可以檢測到我是否從IDE構建而不執行此特定目標?這是我迄今爲止所擁有的。是否有可能在VS IDE中構建時檢測?

<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" /> 

簡單的解決方案是添加另一個構建配置,但我不想這樣做。

此外TeamCity輸出被轉儲到輸出窗口有點煩人。 :)

+0

暫時我只在版本的發佈版本中運行它,但仍然有興趣知道是否有可能檢測到構建是否在IDE中完成 – Dave 2010-02-22 21:55:08

回答

9

是的,你可以檢查物業BuildingInsideVisualStudio

所以你的情況,你可以這樣做以下:

<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> 

通知目標的條件。僅供參考,通常我通常是advise against putting condition on targets,但這對他們來說是一個很好的用法。

+0

非常感謝! – Dave 2010-02-24 13:19:08

相關問題