Building a ASP.NET Packaging Site Manager Using NuGet

by Fabio 22. marzo 2011 17.08

Lately I've been studying NuGet, a system for creating packages of code can install a number of features in an existing project or that is being developed.
The operating mechanism is very simple.

A package is a file that has a ".Nupkg" (it's a. zip file) that contains a series of folders and files, including the most important one with the ".Nuspec"which is the manifest of the whole package.
The package must meet a number of conventions that are available in the documentation for developers here.

NuGet was founded for the management of these modules under development, although in Web Matrix, is also used to install extensions at runtime.
This function is very useful in all those cases where you need to make customizations of sites / applications and you want to go to install them without having to hack the code or even better without having to open Visual Studio.

WebPagesAdmin

Searching the internet I find a nice post by Phil Haack, describing a way to create a series of pages to remove, install and update package at runtime.
Having failed to find the source code I decided to follow his way and I extracted the code from the library "System.Web.WebPages.Administration.dll” with reflector.
This step is necessary because many class have been decorated to serve as internal and not public. Haacked is also confirmed this in his post.

NuGetPackageManagerApplication


The project attached, allows you to manage the lifecycle of packages in a asp.net site, is not complete and should be taken only as an example of possible implementation.
In this example we see how powerful a tool like this. NuGet can we package as well as portions of applications to create modifications to the configuration files like web.config. Think for example of having to create a package, once deployed should insert a new module in the web.config. With NuGet is much simpler since it is already provided this functionality by default.

FabioFranzini.NuGet.Package.WebManager.zip (745,50 kb)

Tags: ,

Commenti (5) -

Nick Airdo
Nick Airdo Stati Uniti
30/09/2011 1.39.49 #

Thanks and nice job!  I believe you want to use the dllPackageSource.SelectedItem.Text and not the dllPackageSource.SelectedValue in your OnPreLoad.  It was the only way I could get the onselectedindex to actually choose the correct package source.

Ciao

Rispondi

Fabio
Fabio Italia
10/10/2011 11.33.47 #

Thanks, I'll try to correct the code!

Rispondi

jykfjp
jykfjp Paesi Bassi
09/10/2011 12.45.20 #

hello Fabi ,

I like this idea and code implementation ver much , can I use your code as base in any closed-source project  or commercial project ?

Regards,
Raku

Rispondi

Fabio
Fabio Italia
10/10/2011 11.32.04 #

Of course!

Rispondi

jykfjp
jykfjp Vietnam
08/01/2012 2.29.09 #

When compile it with nuget 1.5 dll and run in browser to install a package ,
it got [Access to the path 'NuGet\Cache' is denied message] as it seems can not recognize the App_data/packages . it works with bundled nuget 1.3 though.

Rispondi

Aggiungi commento




  Country flag
biuquote
  • Commento
  • Anteprima
Loading


About

Fabio Franzini
Fabio Franzini é consulente e MCT Trainer, specializzato principalmente sullo sviluppo e formazione in SharePoint 2010, ASP.NET, SilverLight, JQuery e in generale su tutto quello che ruota intorno alla piattaforma web di Microsoft. ...

Conferenze

WPC2011

Month List