Download all nuget packages to your local server using powershell

by Damiaan Peeters 21. January 2013 09:02

Some time ago I found this script to download the nuget Packages to you local server.  Just for a reference I’ll put it the blog. They way I run this is using the Windows Powershell ISE.

image

I don’t remember where I got the link from.  But I do know when.  That was when nuget was out and I had no way of retrieving missing packages.  Since then, I run this script to our local NAS from time to time.

The Powershell Source

# --- settings ---
$feedUrlBase = "http://go.microsoft.com/fwlink/?LinkID=206669"
# the rest will be params when converting to funclet
$latest = $true
$overwrite = $false
$top = 1500 #use $top = $null to grab all or a number to get TOP 500 packages
# $destinationDirectory = join-path ([Environment]::GetFolderPath("MyDocuments")) "NuGetLocal"
$destinationDirectory = "L:\TEMP\NuGetLocal"

# --- locals ---
$webClient = New-Object System.Net.WebClient

# --- functions ---

# download entries on a page, recursively called for page continuations
function DownloadEntries {
param ([string]$feedUrl)
$feed = [xml]$webClient.DownloadString($feedUrl)
$entries = $feed.feed.entry
$progress = 0
           
foreach ($entry in $entries) {
    $url = $entry.content.src
    $fileName = $entry.properties.id + "." + $entry.properties.version + ".nupkg"
    $saveFileName = join-path $destinationDirectory $fileName
    $pagepercent = ((++$progress)/$entries.Length*100)
    if ((-not $overwrite) -and (Test-Path -path $saveFileName))
    {
        write-progress -activity "$fileName already downloaded" `
                       -status "$pagepercent% of current page complete" `
                       -percentcomplete $pagepercent
        continue
    }
    write-progress -activity "Downloading $fileName" `
                   -status "$pagepercent% of current page complete" `
                   -percentcomplete $pagepercent

    [int]$trials = 0
    do {
        try {
            $trials +=1
            $webClient.DownloadFile($url, $saveFileName)
            break
        } catch [System.Net.WebException] {
            write-host "Problem downloading $url `tTrial $trials `
                       `n`tException: " $_.Exception.Message
        }
    }
    while ($trials -lt 3)
  }

  $link = $feed.feed.link | where { $_.rel.startsWith("next") } | select href
  if ($link -ne $null) {
    # if using a paged url with a $skiptoken like
    # http:// ... /Packages?$skiptoken='EnyimMemcached-log4net','2.7'
    # remember that you need to escape the $ in powershell with `
    return $link.href
  }
  return $null
}

# the NuGet feed uses a fwlink which redirects
# using this to follow the redirect
function GetPackageUrl {
param ([string]$feedUrlBase)
$resp = [xml]$webClient.DownloadString($feedUrlBase)
return $resp.service.GetAttribute("xml:base")
}

# --- do the actual work ---

# if dest dir doesn't exist, create it
if (!(Test-Path -path $destinationDirectory)) {
    New-Item $destinationDirectory -type directory
}

# set up feed URL
$serviceBase = GetPackageUrl($feedUrlBase)
$feedUrl = $serviceBase + "Packages"
if($latest) {
    $feedUrl = $feedUrl + "?`$filter=IsLatestVersion eq true"
    if($top -ne $null) {
        $feedUrl = $feedUrl + "&`$orderby=DownloadCount desc&`$top=$top"
    }
}

while($feedUrl -ne $null) {
    $feedUrl = DownloadEntries $feedUrl
}

Upgrade of blog engine succeeded

by Damiaan Peeters 12. February 2012 22:23

After running my blog for almost 3 years on BlogEngine.Net version 1.5, I’ve finally made some time to upgrade to the latest and greatest BlogEngine.Net 2.5.  The only difference is that I reactivated comments using Disqus!

So, feel free to send me some comments, or catch me on twitter!

10 jaar .net ervaring

by Damiaan Peeters 26. July 2011 23:40

Net gezien…  Je vraagt je af of die persoon de dubbele shiften heeft meegeteld…

image

Voor de niet kenners, op 16 januari 2002 verscheen versie 1.0 van .NET.

Tags:

General | Internet

How to show off with cmd

by Damiaan Peeters 25. January 2011 23:30

If you use CMD.exe, then just hit F7.  It will give you all previous commands as shown in the screenshot below.

image

Oh btw, because I almost forgot.  There is a easy command prompt to create a new file.

copy con filename.txt

Hit return, just type your text and and with CTRL + Z (and return). You will now have a file with the content you wanted.  Thanks to Scott Hanselman for reminding me!

How to save on your DevExpress subscription

by Damiaan Peeters 22. December 2010 18:11

Normally you would guess that the price goes down when you order for a longer period.  Not with DevExpress components.  It depends on the date until when you want your subscription to be extended. 

I made some calculations.  Apparently there can be a difference of more than $ 0,25 PER DAY for your subscription.

image

So how to save with devexpress subscriptions.  You try to find:

  • a coupon code for your devexpress subscription
  • ask a quote
  • find the best date

I hope it helps you Smile

Notepad font size is adjustable

by Damiaan Peeters 4. November 2010 13:20

Notepad is a stripped down of wordpad.  My guess.   Just see this screenshot and judge yourself!

image

Noticed the changes in the font size?

How to promote your software on social media

by Damiaan Peeters 30. August 2010 12:53
Trillian has a nice example.  Trillian is a instant messenger, combining MSN, ICQ, GTalk, Facebook chat and many others (XMPP/Jabber) into one program.  They also have integration of twitter, facebook and LinkedIn status updates…  Very handy indeed.

So back to the example. 

One of the first times you start, you get this screen: image

The intentions are not hidden…  The screen titles: “Promote Trillian!” Your users have just to push the buttons where they want to let the world know they are using Trillian.  If they like your program, they have no reason no too…

Myspace finally knows

by Damiaan Peeters 27. June 2010 12:55

WOOOW… Myspace finally understands that we do NOT speak French as mother tongue.

Until now i always got myspace in French, which is very frustrating.  I couldn’t change it to English.  I do understand French, but my English reading is more fluent.

image

Thank you!

Side note about languages for foreign companies thinking about entering Belgian market.  Belgium is small, nevertheless it has 3 (!) official languages: Dutch (59%), French (40%) and German (1%) (numbers from wikipedia ).  Most of the Dutch speaking part are more fluent with English than French.  So please consider to supply your site in English if you can’t support Dutch. 

“Change product key Office 2010” option not available

by Damiaan Peeters 13. May 2010 14:02

Ok.  I admit.  I used a borrowed Microsoft Office 2010 key to install the software.  (But, I never clicked the activate button.  Knowing that the software won’t work anymore after 30 days of trial.)
Today, I looked up my MAPS product key and I wanted to change the product key.

I have no option, i say NO option, in outlook/word where i see “Change product key”.  Trust me, I can search.  I wear glasses which cost almost the price of an MS OFfice 2010 suite.

Or what to do what if you activated “by accident” with the wrong serial number.  (Read: I installed unofficially but now i have bought Office 2010 now)

Solution

Fortunately, there is an easy way to change the product key.  One you might not think of instantly.

Reinstall the software… Or just take the “Change product key” option on this screen:

  • Go to Control Panel\Programs\Programs and Features
  • Select Microsoft Office (…) 2010 and click Change on the top of the screen

You will get the following screen.  You can guess it, choose “Enter a Product Key” an hit Continue.

image

The rest of the story is easy…

Taggedmail profile

by Damiaan Peeters 4. January 2010 15:29

This is weird.  Yesterday my traffic on my side got some new traffic.  The website stats showed me (after a little bit of digging), the following figures.

image

Traffic with all the same keyword: “taggedmail profile”.  There were also some visits for the “tagged mail profile”, but much less.  The traffic initiated from different countries, but the majority came from Portugal.  I normally never get traffic from Portugal.    All traffic landed on this page: http://blog.dampee.be/?tag=/mail+profile.  It’s true, the tag “mail profile” is there.  But I doubt it was what they where searching.

I don’t know what it means.  I search Google, I searched Bing.  But couldn’t find any reasonable explanation. My guesses are:

  • spam bots searching for user profiles for email addresses. 
  • some company takeover of which i am not (yet) aware
  • someone interested in buying taggedmail.com (currently pointing to tagged.com)

After these ideas came up, I started searching TechMeme, Mashable and TechCrunch.  But none of them supplied me with some answers, expect for the CSE from Techcrunch: How do I get rid of tagged spam from taggedmail.com? Maybe some spam was send out from the domain taggedmail (.com, .net, …).  But what with the profile keyword?

If someone has any idea, I’ll read it in the comments.

Who.I.am

Certified Umbraco Master, Part of Umbraco Certified partner comm-it, .Net and Azure developer, seo lover. Magician in my spare time.

Month List