始终在Visual Studio 2017中运行生成后事件命令 [英] Always run post build event commands in visual studio 2017

查看:413
本文介绍了始终在Visual Studio 2017中运行生成后事件命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,当我运行我的项目时,它将执行我设置的构建后命令.但是,只有在项目进行了更改时,这才是正确的.我的最终目标是在每次构建项目时都运行我的项目.但是,我注意到的是,如果要按角度更改HTML文件,则该项目不会检测到任何更改,因此不会再次生成,因此不会运行ng build命令.

Currently, when I run my project, it will execute my post-build commands that I have set up. However, this is only true if there was a change to the project. My ultimate goal here is to have my project run ng build each time I build it. However, what I have noticed is that if I were to change an HTML file in angular, the project does not detect any changes so it does not build again and thus it does not run my ng build command.

是否有一种方法可以强制它始终运行生成后命令,或者即使没有检测到更改也可以使其始终重建?也许还有另一种方法可以做到这一点?

Is there a way to force it to always run post-build commands or maybe make it always rebuild, even if no changes are detected? Or maybe there is another way to accomplish this?

这是.NET Core WebApp,运行我的post build事件的代码位于我的.csproj文件中

This is a .NET Core WebApp and the code to run my post build event is located inside my .csproj file

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
    <Exec Command="echo Building Angular App..." />
    <Exec Command="cd ClientApp &amp;&amp; ng build" />
</Target>

推荐答案

我已经通过在项目文件中添加以下属性来解决了这个问题

I have solved this by adding the following properties to my project file

<RunPostBuildEvent>Always</RunPostBuildEvent> 
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>

其他人将此问题作为答案发布,但由于某种原因被删除,因此我将其重新发布,以便以后出现的任何人都可以看到我是如何解决的.

Somebody else had this posted as an answer but deleted for some reason so I am re-posting it so anyone that comes along in future can see how I solved it.

这篇关于始终在Visual Studio 2017中运行生成后事件命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆