问题描述
我提出一个更明确的问题.
I open a clearer question.
如何在.NET项目中的预编译脚本上使VS2015使用通过npm全局安装的angular-cli工具(ng
)来构建Angular2-cli项目.
How is it possible on precompile script in a .NET project, to make VS2015 build the Angular2-cli project with angular-cli tools (ng
) installed globally via npm.
步骤: -npm install -g angular-cli
-在VS2015下的.NET项目中,在F5(内部版本)上,我们需要调用ng build
.
Steps: - npm install -g angular-cli
- In our .NET project under VS2015, on F5 (build) we need ng build
to be called.
我们尝试过:
"precompile": [ "npm install -g angular-cli", "npm install", "ng build --prod" ],
但是我在VS2015控制台上遇到错误.完整日志: http://pastebin.com/RMiU6eMe
But I encounter errors on VS2015 console. Full logs: http://pastebin.com/RMiU6eMe
VS2015似乎无法使用全局安装的ng
命令.
VS2015 doesn't seem to manage to use globally installed ng
command.
我尝试在脚本中通过npm install直接调用在package.json中声明的本地安装的ng
工具:
I tried in our script to call directly the ng
tool installed locally as declared in our package.json via npm install:
"precompile": [ "npm install", "node_modules/angular-cli/bin/ng build --prod" ],
但是VS2015的回答如下:
But VS2015 answers as below:
在构建VS2015之前,我不想与命令行ng build
分开运行(顺便说一句...).
I don't want to have to run separately from command line ng build
(which works by the way...) BEFORE being able to build on VS2015.
推荐答案
在package.json
中添加命令"build": "ng build",
,然后运行npm build
而不是尝试运行ng构建.
Add a command "build": "ng build",
in your package.json
, then, instead of trying to run the ng build, just run the npm build
.
您还可以将其添加到package.json中,以便在每次构建解决方案时将其捆绑.
You can also add this to your package.json to bundling it each time you build your solution.
"-vs-binding": { "BeforeBuild": [ "build" ] }
这篇关于使VS2015在.NET项目中的构建时使用角度倾斜的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!