在Visual Studio 2017中设置gulp的正确方法是什么? [英] What is the correct way to set up gulp in Visual Studio 2017?

查看:979
本文介绍了在Visual Studio 2017中设置gulp的正确方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio 2017中苦苦挣扎。我不确定我要出错的地方,但是有一些我很困惑,而且我也找不到任何在线资源这些都是有用的。



我使用的构建系统是CruiseControl.NET,我希望gulp能够使用它。



这是我迄今为止所做的:


  • 安装了带有<$ c的Visual Studio 2017 $ c> .NET核心跨平台开发和选定Node.js开发(以及其他选项)。


  • 创建一个新项目

  • 添加一个 gulpfile.js 文件到项目
  • 右键单击文件并选择任务运行资源管理器




在Task Runner资源管理器中,我收到错误加载失败。请参阅输出窗口(Ctl + Alt + O)以获取更多信息。

然后,如果我执行以下操作:


$ b


  • 打开Node.js交互式窗口

  • 运行命令 .npm install --global gulp-cli


  • 关闭Visual Studio并重新打开它。




在Task Runner资源管理器中,我收到消息(找不到任务)

首先,这是在Visual Studio 2017中设置Gulp的正确方法吗?

我问这个问题的原因是因为我不知道为什么我需要以句点字符作为前缀命令(即 .npm 而不是 npm )。



我也不确定在哪里安装了gulp,因为我找不到路径 C:\ Program Files(x86)\ Microsoft Visual Studio\2017\Professional\Web\External\\\
ode_modules



正因为如此,我不能重新盟友设立了CruiseControl.NET。

解决方案

微软现在已经添加了关于如何让gulp运行的文档:
https://docs.microsoft.com/zh-cn/aspnet / core / client-side / less-sass-fa#启动



确保您将Visual Studio 2017更新为最新版本它现在随附了Node.js,NPM和Gulp。



在您的项目文件夹中创建一个npm配置文件(package.json)并将其编辑为引用gulp:

  {
version:1.0.0,
name: asp.net,
private:true,
devDependencies:{
gulp:3.9.1
}
}

从命令行运行命令 npm install 开发机器并将此命令添加到构建服务器上的构建脚本中。



如果您计划然后运行命令 bower init



在项目文件夹中,创建一个Gulp配置文件(gulpfile。

将命令 gulp 添加到构建服务器上的构建脚本中。如果要指定要运行的路径或任务,命令将类似于 cmd.exe / c gulp -bC:\Documentation \Wiki--color --gulpfile C:\Documentation\Wiki\Gulpfile.jssite.css 您可以通过右键单击任务并选择运行来获取Visual Studio使用的完整命令,然后Task Runner Explorer将输出它运行的命令。



要在Visual Studio 2017中运行任务,请打开Task Runner Explorer(查看>其他Windows>任务运行器资源管理器)。


I'm struggling to get set up with gulp in Visual Studio 2017. I'm not sure where I'm going wrong but there are a few things I'm confused about and I can't really find any online resources that are of any use.

The build system I'm using is CruiseControl.NET and I would like gulp to work with it.

This is what I've done so far:

  • Installed Visual Studio 2017 with .NET Core cross-platform development and Node.js development selected (amongst other options).

  • Created a new project

  • Added a gulpfile.js file to the project

  • Right-click on the file and choose Task Runner Explorer

In the Task Runner Explorer I get the error Failed to load. See output window (Ctl+Alt+O) for more information..

Then if I do the following:

  • Open the Node.js Interactive Window

  • Run the command .npm install --global gulp-cli

  • Close Visual Studio and open it back up again

In the Task Runner Explorer, I then get the message (No tasks found).

First off, is this the correct way to set up Gulp in Visual Studio 2017?

The reason I'm asking this is because I'm not sure why I need to prefix commands with a period character (ie .npm as opposed to npm).

I'm also not sure where gulp was installed because I can't find it in the path C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Web\External\node_modules.

Because of this I can't really set up CruiseControl.NET.

解决方案

Microsoft have now added documentation on how to get gulp running: https://docs.microsoft.com/en-us/aspnet/core/client-side/less-sass-fa#getting-started

Make sure you update Visual Studio 2017 to the latest version as it now comes shipped with Node.js, NPM and Gulp.

Create an npm Configuration File (package.json) in your project folder and edit it to reference gulp:

{
  "version": "1.0.0",
  "name": "asp.net",
  "private": true,
  "devDependencies": {
    "gulp": "3.9.1"
  }
}

Run the command npm install from the command line on the development machine and add this command to the build script on the build server.

If you plan on using bower then run the command bower init.

In the project folder, create a Gulp Configuration File (gulpfile.js) to define the automated process.

Add the command gulp to the build script on the build server. If you want to specify the path or the task you want to run the command will look something like cmd.exe /c gulp -b "C:\Documentation\Wiki" --color --gulpfile "C:\Documentation\Wiki\Gulpfile.js" site.css. You can get the full command Visual Studio uses by right-clicking on the task and choosing "Run" and then Task Runner Explorer will output the command it ran.

To run the tasks in Visual Studio 2017, open the Task Runner Explorer (View > Other Windows > Task Runner Explorer).

这篇关于在Visual Studio 2017中设置gulp的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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