⬅ Bradenkoh.com

Build Inside Visual Studio Condition

#Programming

There exists a condition inside your .csproj file where you can set a condition to run only if the build is taken place inside visual studio

The xml looks something like this

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

  <Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(BuildingInsideVisualStudio)' == 'true'">
    <Exec Command="echo Hi There!" />
  </Target>

</Project>

This is useful if you have local post build events and don't want them to run inside an Azure pipeline.