[英]How can I automatically execute gulp task when I publish an application using Visual Studio?
I am using gulp with an ASP.NET MVC project.我在 ASP.NET MVC 项目中使用gulp 。 I have Task Runner Extension installed in my Visual Studio 2013 Pro.
我的 Visual Studio 2013 Pro 中安装了Task Runner Extension 。
Every time I publish a new version to the server, I have to always remember to first run a task that generates my publish resources "production ready".每次我向服务器发布新版本时,我都必须始终记住首先运行一个任务来生成我的发布资源“生产就绪”。
Is there a way to setup the project where it always executes a gulp
command line before it publish?有没有办法设置项目,它总是在发布之前执行
gulp
命令行?
Here is the command that I am looking to execute这是我要执行的命令
cmd.exe /c gulp -b --gulpfile "gulpfile.js" production
As Yury suggested, you'll need to add build events to your project. 正如Yury建议的那样,您需要在项目中添加构建事件。
Right click on your project name > "Properties". 右键单击项目名称>“属性”。 On the the left menu click on "Build Events"
在左侧菜单上单击“构建事件”
Then paste the following code in the "Pre-build" area 然后将以下代码粘贴到“预构建”区域中
chdir /d "$(ProjectDir)"
if $(ConfigurationName) == Production (
gulp production
)
The above code first changes the current working directory to the location of your project. 上面的代码首先将当前工作目录更改为项目的位置。 Then based on the configuration name you have selected it with execute the
production
task for gulp. 然后根据您选择的配置名称执行gulp的
production
任务。
您可以创建自定义构建配置以与DEBUG和RELEASE一起发布,并在构建后阶段运行此命令
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.