3

I have a project which has a post build event. When I commit the changes to my Bitbucket account, the CI pipeline runs and attempts to run the post build event as well. This post build event is only needed for local builds and I do not want it to run on CI. Is there any way to configure the post build event to only run through visual studio?

The post build event looks like this:

"C:\Projects\LicenseToolkit\LicenseToolkit\bin\Release\netcoreapp3.1\ApplyLicense.exe" $(TargetDir)

Is there any way to add a condition to it? I know there's a way to do it by editing the csproj file and adding a Condition attribute to the event but I'd like to know if it can be done on the editor in the Properties window.

Thanks a lot!

Codehack
  • 323
  • 2
  • 13
  • How the ci pipeline triggered the build of project ? – Chetan May 03 '20 at 02:11
  • @ChetanRanpariya It runs dotnet build to build the project. – Codehack May 03 '20 at 02:25
  • 1
    Does this answer your question? [How to differentiate TFS Builds and manual builds using macros in Post build event](https://stackoverflow.com/questions/25505368/how-to-differentiate-tfs-builds-and-manual-builds-using-macros-in-post-build-eve) – Klaus Gütter May 03 '20 at 05:44

1 Answers1

2

If you locally build inside Visual Studio, can you use $(BuildingInsideVisualStudio)? At least I found it is working on Visual Studio 2019 16.8.3

  <Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(BuildingInsideVisualStudio)' == 'true'">
    <Exec Command="(This command is executed only in VS)" />
  </Target>

Actually, I met a similar issue, and I referred to the ticket below:

https://github.com/dotnet/project-system/issues/4455

Also see the document below:

Visual Studio integration (MSBuild)

Ryo Asai
  • 1,088
  • 1
  • 6
  • 14