.NET Blog

Tony Cavaliere

 
My Favourite Albums
  And the Grappa wins.
E-mail me Send mail

Disclaimer

Hey unlike other bloggers I stand by what I say but just in case. The opinions expressed herein are my own except on Tuesday when the second card is not turned up otherwise it ain't worth squat.

© Copyright 2012

Number of NuGet Packages Increases Dramatically

Last week I posted a PowerShell script that downloads all the NuGet packages from the NuGet Feed.

At that time the number of packages was an astounding 393. Five days later that number has increased by 100.

Adding third party libraries to your .NET projects has never been easier!

Currently rated 1.3 by 4 people

  • Currently 1.25/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by CynotWhyNot on Saturday, January 22, 2011 12:34 AM
Permalink | Comments (0) | Post RSSRSS comment feed

Creating a Complete Local NuGet Repository

I can’t say enough about it, NuGet is great!

NuGet is a .NET package management system integrated into VS2010. It is available as part of the ASP.NET MVC 3 download or separately from Codeplex. It’s free and open source and makes adding third party (or in house) libraries a snap.

Out of the box, the NuGet packages are retrieved from the internet, however, with very little configuration NuGet can retrieve packages locally or from a shared drive. Phil Haack as excellent post describing this configuration.

Steve Michelotti has an excellent post on how to use PowerShell to automatically pull down the NuGet packages from the internet an store them locally. The script is based on an early version of NuGet. Since then the location for the packages has changed, furthermore, the new feed will only list 100 packages at a time.

I have expanded on Steve’s PowerShell script allowing all the packages to be downloaded:

   1: $webClient = New-Object System.Net.WebClient
   2:  
   3:  $feed = [xml]$webClient.DownloadString("http://packages.nuget.org/v1/FeedService.svc/Packages()")   
   4:  $destinationDirectory = "C:\dev\nuget-lib"   
   5:  $records = $feed | select -ExpandProperty feed | select -ExpandProperty entry | select -ExpandProperty content                        
   6:  
   7:  while($records.Length -gt 0)
   8:  {
   9:      for ($i=0; $i -lt $records.Length; $i++) {   
  10:          $url = $records[$i].src   
  11:          $start = $url.IndexOf("/Download/") + 10
  12:          $packageAndVersion =  $url.Substring($start, $url.Length - $start)
  13:          $package = $packageAndVersion.Substring(0, $packageAndVersion.IndexOf("/"))
  14:          $start = $packageAndVersion.IndexOf("/") + 1
  15:          $len = $packageAndVersion.Length - $packageAndVersion.IndexOf("/") -1
  16:          $ver = $packageAndVersion.Substring($start, $len)
  17:          
  18:          $fileName = $url.Substring($startOfQuery, $url.Length - $startOfQuery)  
  19:          $fullPath = ($destinationDirectory + "\" + $fileName)  
  20:          write-host "Created package: $package.$ver.nupkg"
  21:          $webClient.DownloadFile($records[$i].src, ($destinationDirectory + "\" + $package + "." + $ver + ".nupkg"))  
  22:      }
  23:      $feed = [xml]$webClient.DownloadString("http://packages.nuget.org/v1/FeedService.svc/Packages()?`$skiptoken='$package','$ver'")
  24:      $records = $feed | select -ExpandProperty feed | select -ExpandProperty entry | select -ExpandProperty content
  25:  }

 

The trick is to continue querying the feed until all the packages are downloaded. The feed will only list 100 packages at a time. I could not find any way to override this behaviour. Fortunately, the feed contains the URL to fetch the next set of packages (Fiddler to the rescue). This is done on line 23 of the Powershell script, which adds the $skiptoken to the end of the URL.

The script will deposit all the NuGet packages to a local directory c:\dev\nuget-lib (line 4). Go ahead and change the location to meet your needs.

At the time of writing this post the feed had a total of 393 packages. That ‘s right 393 packages!

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: .NET | ASP.NET MVC | VS2010
Posted by CynotWhyNot on Saturday, January 15, 2011 6:34 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Why I like Windows Server 2008 R2

Windows Server 2008 R2 was recently released on October 22, 2009. I have already used Windows Server 2008 and enjoyed many of it’s new features but this latest release has got me excited and all for one new feature, Remote Desktop multi-monitor support.

Currently I am remoting  to a Windows Server 2008 computer, my local computer runs Windows 7. Remote Desktop Connection available on Windows 7 has support for multiple monitors however the computer you are remoting must also supports multiple monitors remotely. Both Windows 7 and Windows Server 2008 R2 have this build-in capability. All you need to do is enable it from your local machine and remote to the destination computer and sit back and enjoy. I’ve tried it (Windows 7 local and Windows Server 2008 R2 remote) and it work without any issues.

So all you remote users out there rejoice and celebrate your productivity has just increased.

 

image

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by cynotwhynot on Saturday, October 24, 2009 10:18 AM
Permalink | Comments (97) | Post RSSRSS comment feed

Where’s the MDF?

I’ve always wondered why the ASP.NET folks have always had (or at least since VS2005) the ability to add a detached SQL Express file, or commonly referred to as an MDF file, whereas, project types like console application and windows forms do not.

When you add a new item to an ASP.NET application you will see the following dialog.

image

Notice the SQL Server Database option. Selecting this will cause an MDF file to be added to the ASP.NET application. Very convenient. However, no such option exists for either the console or windows forms project types.

I have seen developers add MDF files by starting SQL Server Management Studio, creating a database, detaching it and then coping the file to the project. I have also seen developers create an ASP.NET project, add a MDF file and then copy the MDF to the desired project. Neither are optimal.

One great way to automate this, is to create an Item Template. To do this create an ASP.NET project and then add an MDF file by selecting Add New Item menu option and selecting SQL Server Database. This will add a detached SQLExpress database file to the project. The next step is to delete the LDF (log) file from the project.

Now we are ready to create the Item Template. Select the File->Export Template menu. This causes the Export Template Wizard to appear,a s shown below.

image  

Select the Item template radio button and click the Next > button. The Select Item To Export dialog appears from which you select the MDF file.

image

The next dialog to appear after selecting the Next > button is the Select Item References dialog. In this situation there is no need to include any references so just click the Next > button. The Select Template Options dialog appears from which you specific the name of the template. When done select Finish and that’s it you have created a item template that can be used just about everywhere.

Try it out, create a console application and then select the Add->New Item menu item. If all goes well you should see the Add New Item dialog and under the My Templates you should see the new Item Template. Selecting this Item Template will add a SQLExpress MDF file to the project.

image

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Posted by cynotwhynot on Wednesday, October 07, 2009 4:37 PM
Permalink | Comments (98) | Post RSSRSS comment feed

Expression 3 Screen Capture – Dual Monitor

I’ve been playing around with Expression 3 Encoder and Screen Capture and I must say, pretty impressive. The screen capture is extremely easily to use and has build-in support for overlays. In fact, the PIP webcam feature is automatically overlayed onto the video. This makes it easy to include the presenter in a small window, the location of which can be configured.

One thing that surprised me was the recognition that I was running dual monitor and that Expression Screen Capture was able to capture both screens. Wow!

Below are two videos, hosted on Silverlight Streaming, I capture using Expression 3. The video on the left shows the capture of the dual monitors, while the second contains a capture of a high definition video. Unfortunately, Expression 3 Encoder does not support the Publish To Silverlight Streaming option. I had to manually upload the videos to the Silverlight Streaming Service. Hopefully that plug-in will be made available shortly.

To enter full screen mode double click. Likewise, to exit full screen double click again.

Expression 3 has taken video to the next level!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: Expression | Silverlight
Posted by CynotWhyNot on Wednesday, September 02, 2009 2:54 PM
Permalink | Comments (463) | Post RSSRSS comment feed