简体   繁体   English

使用 Visual Studio 发布应用程序时如何自动执行 gulp 任务?

[英]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

http://gulpjs.com/ http://gulpjs.com/

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.

相关问题 我无法使用 Visual Studio 2019 中的 Google Cloud Platform 工具将 App Engine 应用程序发布到 GCloud - I can't publish a App Engine application to GCloud using the Google Cloud Platform tools in Visual Studio 2019 如何获取visual studio用于发布我的应用程序的clickonce构建脚本 - How can I get the clickonce build script used by visual studio to publish my application 如何使用Visual Studio在C#应用程序中发布Access数据库? - How do I publish an Access database with my C# application using Visual Studio? 如何从Visual Studio发布中排除bin文件夹? - How can I exclude the bin folder from Visual Studio publish? 如何在 Intranet 上发布源代码 (Visual Studio)? - How can I publish source code (Visual Studio) on a intranet? 发布时,Visual Studio中的AssemblyName错误 - AssemblyName in Visual Studio error when i publish it 如何使用通过Visual Studio 2015发布的OneClick发布.NET应用程序? - How do I publish a .NET application with OneClick publish through Visual Studio 2015? 如何使用ClickOnce自动更新Visual Studio应用程序? - How do I update my Visual Studio application automatically using ClickOnce? 使用 Visual Studio 时可以自动增加文件构建版本吗? - Can I automatically increment the file build version when using Visual Studio? (Visual Studio) 如何将 powershell 脚本导入 c# 项目,以便我可以将 .NET 应用程序与脚本一起发布 - (Visual Studio) How to import powershell scripts into c# project so that I can publish my .NET application together with the scripts
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM