【问题标题】:Error installing bower packages in Visual Studio 2015 for ASP.NET Core project在 Visual Studio 2015 for ASP.NET Core 项目中安装 bower 包时出错
【发布时间】:2016-04-12 16:05:56
【问题描述】:

我正在按照迁移建议将 MVC5 网站转换为 ASP.NET Core 网站 - http://docs.asp.net/en/latest/migration/mvc.html,但在尝试使用 Bower 安装客户端包(Bootstrap 和 jQuery)时遇到问题。

我创建了一个空的 ASP.NET 5 Web 应用程序,然后创建了一个 bower.json 文件,但是当我保存它时,我在输出窗口中得到以下内容

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 jquery#2.1.4 --production --force-latest --save
bower jquery#2.1.4          not-cached https://github.com/jquery/jquery-dist.git#2.1.4
bower jquery#2.1.4             resolve https://github.com/jquery/jquery-dist.git#2.1.4
bower jquery#2.1.4            checkout 2.1.4
bower jquery#2.1.4             ECMDERR Failed to execute "git clone https://github.com/jquery/jquery-dist.git -b 2.1.4 --progress . --depth 1", exit code of #-532462766

我也尝试在 VS 中使用 Bower 包管理器,结果相同

我正在使用 Visual Studio 2015 Update 2 和 ASP.NET Web Tools RC1-update 1

当这不起作用时(有不同的错误),我看过其他帖子,但那些是在公司防火墙/代理后面时,我不是

我不熟悉这个 npm/bower 的东西。我错过了什么?


更新: 我在命令提示符下运行了命令,但它仍然不起作用,但我确实有更多关于潜在错误的详细信息

Unhandled Exception: System.MissingMethodException: Method not found: 'LibGit2Sharp.Branch LibGit2Sharp.RepositoryExtensions.Checkout(LibGit2Sharp.IRepository, LibGit2Sharp.Branch, LibGit2Sharp.Signature)'.
   at Microsoft.VisualStudio.GitCli.GitShim.clone(String url, String workingDirectory, String branchName)
   at Microsoft.VisualStudio.GitCli.Program.Main(String[] args)

找到了这个链接,其他人似乎也有同样的问题https://connect.microsoft.com/VisualStudio/feedback/details/1322649/bower-cannot-get-packages-with-protocol-git-since-behind-a-firewall

所以看起来是一个问题,MS 发布了这个组件的错误版本

【问题讨论】:

  • 我也有同样的问题。你修好了吗?
  • 安装独立 git 并检查 PATH 变量是否已设置。

标签: asp.net-core


【解决方案1】:

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

  • 安装来自http://git-scm.com/的独立Git

  • 打开 bash 和 执行 以在 git 上使用 https 代替(防火墙可能会阻止 git 协议):

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

  • 配置 Visual Studio 改为使用这个新的 git 工具:

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

希望对你有帮助

【讨论】:

    【解决方案2】:

    尝试打开命令窗口并运行“git clone .....”命令。如果它有效,那绝对意味着它不是代理/防火墙问题,更有可能是 Git 和 VS 的问题。

    为了解决这个问题,我下载了独立的 git 安装程序 (downloader here),它对我有用。

    【讨论】:

    • 在提示符下运行命令后,我在原始问题中添加了更多详细信息。你认为安装 GIT 客户端会是一种解决方法吗?
    • @David 可能。他们在那个链接上提到 VS 使用了 git 的精简版,所以完整版可能就可以工作。
    • 按照此处的说明安装 GIT 客户端,它使我能够解决问题stackoverflow.com/a/31538406/4186852
    • 当然你还需要告诉VS使用外部git。这可以在 VS 选项中完成,David 的链接对此提供了更多信息。
    猜你喜欢
    • 1970-01-01
    • 2017-04-02
    • 2017-03-23
    • 2017-08-05
    • 2015-12-22
    • 2017-02-21
    • 2016-07-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多