我可以将 Grunt 与 TFS 一起使用吗? [英] Can I use Grunt with TFS?

查看:37
本文介绍了我可以将 Grunt 与 TFS 一起使用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的新项目需要我使用 TFS + Git.

My new project needs me to work with TFS + Git.

坦白:我对 TFS 一无所知.

Confession: I know nothing about TFS.

我想为我的 JavaScript 项目设置构建版本.我想使用 Grunt.

I want to setup a build for my JavaScript project. I want to use Grunt.

这可能吗?有人在 TFS 中使用过 Grunt 吗?

Is this possible? Has anybody used Grunt with TFS?

推荐答案

在我们当前的项目中,我们使用 Grunt 和 TFS.我已经将 Grunt 与 TFS 集成在一起,方法是从一个 bat 文件中对其进行校准,您可以将其连接到 项目文件的构建前或构建后部分.

On our current project, we're using Grunt and TFS. I've integrated Grunt with TFS by caling it from a bat file which you can hook up in the Pre- or Post-BuildEvents section of your project file.

但是,由于 TFS 将使用特定的环境变量执行您的构建,因此您需要使用绝对路径.

However, because TFS will execute your builds with specific environment variables, you need to use absolute paths.

我们做过的事情的清单

  1. 在您的构建机器(当然也包括您的开发机器)上安装 node.js
  2. 在您的 JavaScript 项目的根目录中添加一个 package.json 文件.
  3. 使用 npm 安装 grunt-cli 本地 (!).使用 --save-dev 标志将此包添加到 package.json
  4. 中的开发依赖项部分
  5. 对于您需要的所有其他包,使用具有与步骤 3 中相同标志的 npm
  6. 编写一个 bat 文件(参见下面的示例),您将在其中
  1. Install node.js on your build machine (as well as on your development machine(s) ofcourse)
  2. Add a package.jsonfile on the root of your JavaScript project.
  3. Use npm to install grunt-cli locally (!). Use the --save-dev flag to add this package to the development dependencies section in package.json
  4. For all other packages you need, use npm with the same flag as in step 3
  5. Write a bat file (see example below) in which you'll
  1. 使用绝对路径
  2. 使用 npm 安装 packages.json 文件中列出的所有包
  3. 呼噜声

  • 在您的 Pre- 或 PostBuildEvents 中,调用此 bat 文件
  • bat 文件示例

    rem use call to execute other bat files
    echo npm install 
    call "C:Program Files
    odejs
    pm" install
    
    rem because we have listed grunt-cli as a dev dependency,
    rem the executable will be located in the node_modules folder
    echo grunt
    call "./node_modules/.bin/grunt"
    

    这篇关于我可以将 Grunt 与 TFS 一起使用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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