简体   繁体   English

如何仅通过 Visual Studio 运行构建后构建事件

[英]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.当我将更改提交到我的 Bitbucket 帐户时,CI 管道运行并尝试运行构建后事件。 This post build event is only needed for local builds and I do not want it to run on CI.仅本地构建需要此构建后事件,我不希望它在 CI 上运行。 Is there any way to configure the post build event to only run through visual studio?有没有办法将构建后事件配置为仅通过 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.我知道有一种方法可以通过编辑 csproj 文件并向事件添加 Condition 属性,但我想知道它是否可以在 Properties window 中的编辑器上完成。

Thanks a lot!非常感谢!

If you locally build inside Visual Studio, can you use $(BuildingInsideVisualStudio)?如果您在 Visual Studio 中本地构建,可以使用 $(BuildingInsideVisualStudio) 吗? At least I found it is working on Visual Studio 2019 16.8.3至少我发现它在 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 https://github.com/dotnet/project-system/issues/4455

Also see the document below:另请参阅以下文档:

Visual Studio integration (MSBuild) Visual Studio 集成 (MSBuild)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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