Setting Up a Local NuGet Gallery

For a while now I’ve been wanting to hook up our continuous integration process with a local NuGet gallery. The basic idea is for the build process to produce NuGet packages containing components that are used across a number of internal developments. These packaged up components would then be published to a local NuGet gallery where the packages could be located by internal developers and pulled down into projects in Visual Studio that have a dependency on those components. Jetbrains announcement of native support for NuGet within their TeamCity application made this integration even more attractive.

At the time of writing the NuGet documentation on setting up a local gallery server is a little out of date, referring to an older version of the gallery. What follows is a simple set of instructions on getting a local gallery setup.

The NuGetGallery that I wanted to work with is an implementation of the Gallery and OData package feed that runs the http://nuget.org/ site. You’ll need to download the code for the NuGetGallery from GitHub where it’s available as a zip archive or via a read-only GIT repository.

Once you’ve pulled down a copy of the NuGetGallery project make sure that you have the necessary software installed to compile the project. You’ll need:

Both Powershell and the Windows Azure SDK can also be installed via the Microsoft Web Platform Installer.

Building the project

During the process of building the project a new database will be created for the gallery. By default this will be created in the local SQLEXPRESS instance on the build machine. If you need to change the database setup details the simplest approach is to edit the web.config file in the WebSite folder. The default connection string settings are shown below.

  <connectionStrings>
    <add name="NuGetGallery"
            connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=NuGetGallery;Integrated Security=SSPI"
	    providerName="System.Data.SqlClient" />
  </connectionStrings>

Start a command prompt with elevated credentials in the folder that contains the NuGetGallery project. You can either run the windows command prompt as an Administrator or take a look at this post for details of a handy registry hack to add a “Open Command Window Here as Administrator” to the context explorer menu.

Type powershell followed by ENTER to start a windows powershell.

.\Build-Solution.ps1 to invoke the build script

Tip: If the script fails to run and powershell reports that the execution of scripts is disabled on this system the following command should amend the shell execution policy to allow  the script to execute:

C:\PS>set-executionpolicy remotesigned

The Build-Solution script does a whole heap of stuff and is guaranteed to wow your boss if he catches sight of the impressive output that it generates.

Running the Gallery

After the script completes successfully point a web server at the WebSite folder, either a full blown IIS or grab a copy of IIS Express or WebMatrix from the Microsoft Web Platform Installer.

Once you’ve got the site running, you should be able to load the basic NuGet gallery site in a browser.

new nuget gallery

The November 2011 issue of MSDN Magazine contains a great article by Phil Haack on how to manage project libraries with NuGet. Put that information together with the Jetbrains blog post on Native NuGet Support in TeamCity and it’s not going to be difficult to put together a build process that pushes out packages that can be viewed on your local NuGet gallery. Finally, the NuGet docs pages have instructions on how to setup Visual Studio to consume packages from your local gallery feed.


ICO advice available on EU’s Cookie Legislation

The Information Commissioner’s Office (ICO) has issued it’s advice on the EU’s Privacy and Electronic Communications Directive that comes into effect on 26th May 2011.

Under the new regulations web sites will not be able to simply rely on the do-not-track browser settings present in Firefox and IE9 in order to comply with the new law, the ICO has said.

The full report can be found on the ICO’s website.

The ICO has yet to publish it’s guidance on how the new regulations are to be enforced, but states:

The key point is that you cannot ignore these rules.

 


Don’t Give Me No Blue Sky Rubbish

I’ve read a fair number of books on software development over the years but the one that has made the most difference to me was I. M. Wright’s ‘Hard Code’. Amazon’s summary states ‘Get the brutal truth about coding, testing, and project management—from a Microsoft insider who tells it like it is’. Fair comment.

Back in the day we had Ed Yourdon telling us all about  Death March  projects and Steve McConnell‘s Code Complete as a self defense guide to how to avoid getting stuck on one.


These days I’ve got Eric Brechner’s blog to provide me with an up-to-date insight into the software development process and it’s incumbant pitfalls. Eric’s hard bitten perspective and practical advice ought to provide enough ammunition for even the most jaded Dilbert devotee to start sorting out their:

  • Career
  • Project
  • Manager [sic]
  • Department / Company

IMHO if ‘Hard Code’ doesn’t speak to you, you’re most likely in the wrong industry.

One final cautionary note, the ‘Hard Code’ blog doesn’t deal in ‘Blue Sky Thinking’ and offers little to those looking to ‘Land their Vision’, those individuals best look elsewhere for what they seek.


ReSharper friendly Visual Studio colour scheme

Looking for a dark visual studio style that’s not high contrast, easy on the eye for all day use and best of all ReSharper friendly then take a peek at Selenitic created by Tim G. Thomas.

Selenitic colour scheme screenshot 

This is just one of many Visual Studio styles available for download at http://studiostyl.es/ a great community site for creating and sharing Visual Studio colour schemes.


Sitecore content tree indexed by Search Engines

Have you noticed that your Sitecore content tree may be indexed by search engines?

Try searching for “/sitecore/content/” in your favourite search engine. When I entered this into Bing the third link that I was shown was:

www.rfu.com

www.rfu.com/sitecore/content.aspx

Clicking on the link takes you to a Page Error message on the RFU site as there’s no layout associated with the content item. The url shown in the browser address bar is:

http://www.rfu.com/error?item=%2fsitecore%2fcontent&layout=%7b00000000-0000-0000-0000-000000000000%7d&device=Default

Presumably having content indexed by search engines under two separate url’s on a site isn’t going to be too good for your SEO rankings unless appropriate action is taken.

One way that I found of successfully dealing with this problem was to add the following to the sites robots.txt file:

User-agent: *
Disallow: /Sitecore/

Can anyone offer a good explanation of what is allowing the structure of the Sitecore CMS’s content tree to be indexed by the search engines?


HTTP 304 response handling in Sitecore MediaRequestHandler

Whilst testing a Sitecore 6.1 site due for release Firebug highlighted some unexpected behaviour from the Sitecore Media Request Handler which takes care of responding to requests for items held in the Sitecore Media Library. Media library items were being returned in full every time that they were requested, each returning a HTTP 200 response status code.

Further digging with Lutz Roeder’s excellent Reflector tool showed that the If-Modified-Since request header field was not being responded to correctly by the MediaRequestHandler. The If-Modified-Since request header is a HTTP-date value whose time component is in the format HH:MM:SS (i.e. no milliseconds). This header field value is used by the Modified method within the MediaRequestHandler to compare to the System.DateTime value that the media library item was last updated. As a System.DateTime value includes a milliseconds component the equality check fails for the majority of media library requests and as a result the item is downloaded to the browser in full.

Sitecore have confirmed that this is a known issue and something that will be fixed in a forthcoming release. In the meantime it’s not difficult to patch in a modified HTTP handler to respond to media library requests and implement HTTP 304 response handling appropriately. Alex de Groot has a good article on his blog that explains how Sitecore interacts with HTTP handlers for media handling.


Follow

Get every new post delivered to your Inbox.