Search code examples
.netvisual-studioprojects-and-solutionsmsbuild-task

Set up a build step executed only when the project is built from Visual Studio but not on the build server


How can I set a build step that is executed only when built from Visual Studio and not on the build server?

I want a build step for local debugging, but I do not want this step to run when my build runs on TeamCity.

Is there a way to do this?


Solution

  • You can execute your logic conditionally on the presence of an environment variable

    Since your question is tagged MSBuild you can do this

    <Project DefaultTargets="Build">    
        <Target Name="Build" Condition="'$(TEAMCITY_VERSION)' == ''">  
            <Message Text="Building..."/>  
        </Target>  
    </Project>