Bower 在 VS 2015 中失败

Bower is failing with VS 2015

上下文:

我正在尝试在我的 VS 2015 Update 2 ASP.NET 4.6 项目中使用 Bower。 Bower 已成功(?)通过项目下的 npm 安装。创建保存 bower.json 后,出现与 git 相关的错误消息。 (见展览)

注:

这不是协议更改问题 (git:// -> https://)。 协议已经是 https.

问题:

如何配置 Bower 以与我的 VS 2015 ASP Web 应用程序一起工作。

bower 输出展示:

PATH=.\node_modules\.bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External;%PATH%;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\git
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\Bower.cmd" install --force-latest
bower jquery-validation-unobtrusive#*       not-cached https://github.com/aspnet/jquery-validation-unobtrusive.git#*
bower jquery-validation-unobtrusive#*          resolve https://github.com/aspnet/jquery-validation-unobtrusive.git#*
bower modernizr#*                           not-cached https://github.com/Modernizr/Modernizr.git#*
bower modernizr#*                              resolve https://github.com/Modernizr/Modernizr.git#*
bower bootstrap#*                           not-cached https://github.com/twbs/bootstrap.git#*
bower bootstrap#*                              resolve https://github.com/twbs/bootstrap.git#*
bower jquery-validation-unobtrusive#*         checkout v3.2.6
bower modernizr#*                             checkout v3.3.1
bower bootstrap#*                             checkout v3.3.6
bower jquery-validation-unobtrusive#*          ECMDERR Failed to execute "git clone https://github.com/aspnet/jquery-validation-unobtrusive.git -b v3.2.6 --progress . --depth 1", exit code of #-532462766

确保该目录中存在 bower.json 名为“.bowerrc”的文件

其内容应为:

{ "directory": "wwwroot/lib" }

这帮我修好了! :)

尝试更新您的 git 版本 (https://git-scm.com/),只需下载最新的二进制文件,确保 VS 已关闭,然后安装。

安装时选择 Windows console 而不是 MinTTY(没试过其他方式)

然后启动 VS 并恢复 bower 包

这帮助我在安装 ASP.NET MVC 6 Boilerplate

时解决了与您完全相同的错误(在 VS 2015 Enterprise + ASP.NET Core RC1 上)

不知道为什么会这样,但我就是这样解决的:

  • http://git-scm.com/

    安装 独立 Git
  • 打开 bash和执行以在git(防火墙可能会阻塞 git 协议):

    git config --global url.https://github.com/.insteadOf git://github.com/

  • 配置 Visual studio 以使用这个新的 git 工具:

    添加最后一行并取消选中旧的git命令行。