简体   繁体   中英

Accessing bower packages in a .NET application

My goal

Get json files from CLDR packages . But obviously not all of them (there are some configuration files) - just the real data .

Idea

As I can see, they're configured for bower . There is also a pattern, which describes where to find those json files within a repository:

{
  "name": "cldr-dates-full",
  "version": "29.0.0",
  "dependencies": {
    "cldr-numbers-full": "29.0.0"
  },
  "main": "main/**/*.json",
  "ignore": [
    ".gitattributes",
    "README.md"
  ]
}

Thus - is it possible to easily download bower packages to a .NET application?

Naive approach

Download each repository, find the bower.json file, navigate to the main property, parse the pattern, extract the files. Very ugly.

Any advice would be very welcome. Thanks!

I'm not sure what type of .Net application you are refering to but if you are using the new Asp.Net Core (Asp.Net 5) together with Visual Studio 2015, there are built in tooling to download npm packages, run gulp/grunt and download dependencies from bower.

http://docs.asp.net/en/latest/client-side/bower.html

Edit. After some discussion maybe Edge.js can help you out. It supports combinibg node.js and.Net.

Bower is a package manager (sort of like NuGet). Just like NuGet, there is a Bower command line utility that can be used to download packages to your local file system. From there, you can add the folders to your project.

# install specific version of a package
$ bower install <package>#<version>

Also, just like NuGet, any packages you have in a local bower.json file...

{
  ... Other stuff omitted for brevity

  "license": "MIT",
  "ignore": [
    "**/.*",
    "node_modules",
    "bower_components",
    "*.json",
    ".git"
  ],
  "dependencies": {
    "jquery": ">= 1.4.2",
  "cldr-segments-modern": ">= 1.0.0"
  }
}

Then you can just use the install command to download them all at once.

$ bower install

Related:

NOTE: If you use Bower frequently from Visual Studio, you might consider How can I add a custom command to Visual Studio?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM