本文介绍了Bower在Visual Studio Team Services上安装依赖于另一个团队项目的构建步骤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在bower.json中,我们具有以下依赖关系:

In our bower.json we have this dependency:

"ourpackage": "git+https://xxx.visualstudio.com/DefaultCollection/_git/ourpackage#1.2.3"

我正在使用备用凭据,这在我的机器上可以正常工作.

I'm using alternate credentials and this works fine on my machine.

当我在Visual Studio Team Services上运行此命令时,它失败了,因为它没有我的凭据.我不想将我的个人备用凭据添加到bower.json文件中.另一个解决方案是不使用Bower即可将文件添加到我们的项目中.

When I run this on Visual Studio Team Services it fails as it doesn't have my credentials. I don't want to add my personal alternate credentials to the bower.json file. Another solution would be to just add the files to our project without using bower.

还有其他解决方法吗?

推荐答案

我遇到了同样的问题,并按如下所示解决了该问题:

I ran across this same issue and fixed it like this:

  1. 确保在构建定义中选择选项">允许脚本访问OAuth令牌".
  2. 在Bower安装命令任务之前,将Powershell脚本任务添加到构建定义任务中

  1. Make sure to select Options > Allow Scripts to Access OAuth Token in the build definition.
  2. Add a powershell script task to your build definition task, before your bower install command task

$file = "path\to\bower.json"

(Get-Content $file| ForEach-Object { $_ -replace "https://your.visualstudio.com", "https://un:$env:SYSTEM_ACCESSTOKEN@your.visualstudio.com" }) | Set-Content $file

我发现的一个警告是,如果您在VSTS上托管了Bower软件包的依赖关系树,则必须将树中的所有依赖关系添加到您的rooter bower.json文件中,即package1在其bower.json文件中包括package2 bower.json-您需要在构建项目的bower.json中同时包含package1和package2.

The one caveat I found is that if you have a dependency tree of bower packages hosted on VSTS, you'll have to add all of the dependencies in the tree to your root bower.json file, i.e. package1 includes package2 in its bower.json - you'll need to include both package1 and package2 in your build project's bower.json.

这篇关于Bower在Visual Studio Team Services上安装依赖于另一个团队项目的构建步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 17:16