开发者

Mirroring the official nuget package repository

开发者 https://www.devze.com 2023-02-04 15:13 出处:网络
At my place of employment we have a temperamental proxy server which often makes the nuget packages window unusable (the same is true for the nuget command line).I\'ve started copying the packages we

At my place of employment we have a temperamental proxy server which often makes the nuget packages window unusable (the same is true for the nuget command line). I've started copying the packages we use most often to a local mirror on a network share, but doing this manually has become tedious. I've experimented with using powershell to download the packages automatically, but can't seem to get the odata ur开发者_StackOverflowi to show more than a few packages. For example running the following query:

$feed = [xml]$webClient.DownloadString("http://feed.nuget.org/ctp2/odata/v1/Packages?$filter=startswith(Title,'O') eq true&$top=100")

Should return the top 100 packages that have a title beginning with 'O', but no packages are returned. Weirdly this works fine with package names that are in the default list of packages returned by hitting http://feed.nuget.org/ctp2/odata/v1/Packages. I'm guessing that there's some kind of paging going on, where I'm only querying over the first page. Playing with the parameters I don't seem to be able to change to the next page...

Has anyone else tried to do this? Has anyone else noticed timeouts/bad requests using nuget?


Jon Galloway posted a PS script that downloads the whole repository. I've used it on a couple of machines and it works great for me.

http://weblogs.asp.net/jongalloway/downloading-a-local-nuget-repository-with-powershell


My suggestion is to use the New-ODataServiceProxy or even Doug Finke's PSOdata project

With just the proxy function you can do this:

New-ODataServiceProxy http://packages.nuget.org/v1/FeedService.svc/ NuGet
 # Chain up calls to AddQueryOption (please excuse my line wrapping):
$NuGet.Packages.AddQueryOption( '$filter',"startswith(Title,'O') eq true"
              ).AddQueryOption( '$top','3' ) |
Format-Table Id, Version, Authors, Description -Wrap -Auto


You need to be careful when using string in double quotes. Try to evaluate the url first, or only a part:

PS> "?$filter=startswith(Title,'O') eq true&$top=100"
?=startswith(Title,'O') eq true&=100

PS> "?`$filter=startswith(Title,'O') eq true&`$top=100"
?$filter=startswith(Title,'O') eq true&$top=100

Escape the dollar sign with backtick.

Then I tried to query the site with (hopefully) correct url, but no result entry was returned. So - still no luck and there could be something wrong with the service.

0

精彩评论

暂无评论...
验证码 换一张
取 消