[英]How do I configure bower with Visual Studio?
As complexity of my web project is growing, I am realizing that downloading external JavaScript libraries manually, is error prone, time consuming and making project less maintainable over time.随着我的 Web 项目的复杂性不断增加,我意识到手动下载外部 JavaScript 库容易出错、耗时并且随着时间的推移使项目的可维护性降低。
Although Visual Studio has NuGet package manager, it is not as powerful as bower.虽然 Visual Studio 有 NuGet 包管理器,但它不如 bower 强大。 Also not all external libraries are being released on NuGet.此外,并非所有外部库都在 NuGet 上发布。
But there is no clear help on how to configure bower with Visual Studio.但是没有关于如何使用 Visual Studio 配置 bower 的明确帮助。 Please help !请帮忙 !
As complexity of my web project grew, I realized that downloading external JavaScript libraries manually, was error prone, time consuming and made project less maintainable over time.随着我的 Web 项目的复杂性增加,我意识到手动下载外部 JavaScript 库容易出错、耗时,并且随着时间的推移降低了项目的可维护性。
Although Visual Studio has NuGet package manager, it is not as powerful as bower.虽然 Visual Studio 有 NuGet 包管理器,但它不如 bower 强大。 Also not all external libraries are being released on NuGet.此外,并非所有外部库都在 NuGet 上发布。
So, I decided to take the plunge and get started with bower.所以,我决定冒险尝试并开始使用 bower。
My project structure is now much cleaner and easy to maintain.我的项目结构现在更加简洁且易于维护。
Here I am listing steps, we need to take to configure bower with Visual Studio.在这里,我列出了使用 Visual Studio 配置 Bower 所需的步骤。
Detailed steps to use bower are already available on http://bower.io/#install-bower .使用 bower 的详细步骤已在http://bower.io/#install-bower 上提供。 Here I will list steps, I took to在这里,我将列出我采取的步骤
— install bower — 安装凉亭
— configure it with Visual Studio — 使用 Visual Studio 进行配置
— download a sample package -- ( AngularJS ) — 下载示例包 — ( AngularJS )
Bower requires node, npm and git for windows. Bower 需要 node、npm 和 git for windows。
Before proceeding ahead, install the following在继续之前,请安装以下内容
Step# 1第1步
Open Command Prompt and execute command打开命令提示符并执行命令
npm install -g bower
Above step may fail, if you are behind corporate proxy server.如果您使用的是公司代理服务器,则上述步骤可能会失败。 To add proxy server settings in npm, execute following 2 commands from command prompt要在 npm 中添加代理服务器设置,请从命令提示符执行以下 2 个命令
npm config set proxy http://proxy.myCompany.com:80
npm config set https-proxy http://proxy.myCompany.com:80
Once done, try installing bower again完成后,再次尝试安装 bower
Step# 2第2步
Navigate to your Visual Studio Project folder from Command Prompt.从命令提示符导航到 Visual Studio 项目文件夹。
Execute command执行命令
bower init
Step# 3第 3 步
Create a .bowerrc file using notepad with following configuration and save it in your Visual Studio Project folder使用记事本和以下配置创建一个 .bowerrc 文件并将其保存在您的 Visual Studio 项目文件夹中
{
"directory": "scripts/bower_components",
"proxy":"http://proxy.myCompany.com:80",
"https-proxy":"http://proxy.myCompany.com:80"
}
Step# 4第四步
To download AngularJs, execute command要下载 AngularJs,请执行命令
bower install angular –save
This will add a line in bower.json.这将在 bower.json 中添加一行。
Step# 5第 5 步
Package will be downloaded under bower_components directory by default.包会默认下载在 bower_components 目录下。 (or under the directory mentioned in .bowerrc file) (或在 .bowerrc 文件中提到的目录下)
Make to sure include the whole package directory in Visual Studio project.确保在 Visual Studio 项目中包含整个包目录。
Step# 6第 6 步
Finally add reference of new package to your index.html最后将新包的引用添加到您的 index.html
I found that I also needed to configure git to use the proxy server :我发现我还需要配置 git 才能使用代理服务器:
git config --global http.proxy http://username:password@proxyURL:8080 git config --global http.proxy http://username:password@proxyURL:8080
After that bower worked in VS 2015在那个凉亭在 VS 2015 中工作之后
The same thing happened to me with Net Core 2.2, I've researched and it looks like Microsoft has stopped using Bower. 我已经研究了Net Core 2.2的问题,微软似乎已经停止使用Bower。
View this link 查看此链接
Bower replacement in Visual Studio 2017 ASP.NET MVC Core Template Visual Studio 2017 ASP.NET MVC核心模板中的Bower替换
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.