简体   繁体   中英

How to run post build-build event only through Visual Studio

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!

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM