我可以将 Grunt 与 TFS 一起使用吗? [英] Can I use Grunt with 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.
我们做过的事情的清单
- 在您的构建机器(当然也包括您的开发机器)上安装 node.js
- 在您的 JavaScript 项目的根目录中添加一个
package.json
文件. - 使用
npm
安装grunt-cli
本地 (!).使用--save-dev
标志将此包添加到package.json
中的开发依赖项部分 - 对于您需要的所有其他包,使用具有与步骤 3 中相同标志的 npm
- 编写一个 bat 文件(参见下面的示例),您将在其中
- Install node.js on your build machine (as well as on your development machine(s) ofcourse)
- Add a
package.json
file on the root of your JavaScript project. - Use
npm
to installgrunt-cli
locally (!). Use the--save-dev
flag to add this package to the development dependencies section inpackage.json
- For all other packages you need, use npm with the same flag as in step 3
- Write a bat file (see example below) in which you'll
- 使用绝对路径
- 使用 npm 安装 packages.json 文件中列出的所有包
- 呼噜声
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屋!