Skip to main content

Patching your .Net website

Whilst re-compiling and re-deploying your entire .Net website application is the “safe” solution to avoid any nasty version conflicts etc its also slow (and a sledge-hammer to crack a nut).

If you are running a live website you often just want a quick patch to fix the issue at hand – often just a single assembly.

If you are lucky (like I was) you have a good build manager to do all this for you… but I have found that people are not always aware of the options available – they just use the Visual Studio GUI to re-compile the entire solution every time.

If you are using Visual Studio to do the build there is no requirement to re-build the entire solution (.sln) every time - you can just rebuild a project (.proj) within the solution so you get just the single assembly. Note that "Build" will only compile changes anyway, "rebuild" will re-compile everything whether it has changed or not.

It's worth moving away from using the GUI (if you haven't already) to using MSBuild.

MSBuild is a dark art to me but there is a lot of reference material out there (http://msdn.microsoft.com/en-us/library/ms171452.aspx , http://blogs.msdn.com/msbuild/ ).

There is also NANT, of course - http://nant.sourceforge.net/http://social.msdn.microsoft.com/forums/en-US/msbuild/thread/994761a3-ea9d-40c7-8d4f-4c208b2023f6/ ,  

Regardless of HOW you build you still need to ensure that you maintain the linkages between the different parts of you application.

There are a number of different ways of doing this to ensure that you maintain the linkages between assemblies.

 

Keeping a static version number

The “easiest way” is to just not change the assembly version number (AssemblyVersionInfo.cs) – to the rest of the site it still looks like the “same version”. You can change the AssemblyFileVersion if you want  so the Operations people can distinguish between the two different version DLL’s on the server (assembly file version is that number you see when you look at the properties of a file in Window Explorer).

[assembly: AssemblyVersion("1.0.262.0")]

[assembly: AssemblyFileVersion("1.0.397.0")]

 

Using Publisher Policy Assembly Redirection

The better way is to use “policy redirection” i.e. use policy files to tell .Net to “give the application 1.1.1.2 even though it asked for 1.1.1.2”.

This is documented here - http://msdn.microsoft.com/en-us/library/7wd6ex19.aspx - but I have shown an example below of redirecting “all versions of ZZZ.Business.AdManager versions 1.0.*.* to version 1.0.262.0”.

<configuration>

  <runtime>

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

      <dependentAssembly>

        <assemblyIdentity name="ZZZ.Business.AdManager" publicKeyToken="6221fee78ae283c6" culture="neutral" />

        <bindingRedirect oldVersion="1.0.0.0-1.0.65535.65535" newVersion="1.0.262.0" />

      </dependentAssembly>

    </assemblyBinding>

  </runtime>

</configuration>

Note that this can be done at different levels too – publisher policy for the assembly, application level and at machine level (machine.config).

There are some pre-requisites e.g. “strong names” but these are easily created as part of the assembly process and you need strong naming if you want to share stuff in the GAC anyway.

 

Further Information

.NET Framework Tutorials - Versioning Components

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptutorials/html/versioning_components.asp

Managing Versions of an Application

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/managevers.asp

The Build Process

http://msdn.microsoft.com/en-us/library/ms998223.aspx

Simplifying Deployment and Solving DLL Hell with the .NET Framework

http://msdn.microsoft.com/en-us/library/ms973843.aspx

VS 2005 Web Deployment Projects

http://weblogs.asp.net/scottgu/archive/2005/11/06/429723.aspx

Web Deployment Tool (even better with IIS7!!!)

http://learn.iis.net/page.aspx/346/web-deployment-tool/

I hope this is information is useful to your build manager and that we will be able to transition to a more flexible deployment strategy in coming releases!

Comments

Popular posts from this blog

So what else does Operations do? Well, there is a whole organisation run by the UK govermnent to help answer that question! ITIL , or the IT Infrastructure Library, is a library of best practice information that basically tells you everything you need to do to run an IT department. Similarly developers have development methodologies such as RAD, JAD, Agile/XP, and Project Managers have PM methodologies such as Prince 2, PMBok etc to cover off their areas in more specific detail. ITIL breaks it down into 7 key areas: Service Support - deals with the actual provision of IT services such as the service (help) desk, incident management, problem management, release management etc Service Delivery - deals with ensuring that you can continue to DELIVER the service support functions with things like contigency planning, capacity management, service levels etc The Business Perspective - helps to ensure that the IT function is aligned with the organisation's business strategy and that how to...

Alexa has performance rankings too!

I must confess that this one had slipped past me… I wasn’t aware that Alexa was now offering performance rankings as well! Alexa now shows an “average load time” as well as a “comparitive ranking” (i.e. 51% of sites are slower). Interesting data for your next website analysis! It’s worth noting that the quoted “1.404 seconds” is about the same as the “repeat view” measurement webpagetest.org (testing from the UK node shows that www.johnlewis.com takes about 7.2 seconds to load with an empty cache, and 1.6 seconds with a primed cache, median values over 5 runs). Presumably this is an average across all Alexa toolbar users, on all johnlewis.com pages (large and small) with empty and primed caches.

It’s been a while...

I haven’t blogged here since Nov 2011 (so 6yrs 3 months and counting) mostly because I’ve been doing all my blogging over at www.devopsguys.com/blog . But as DevOpsGuys has grown as a company I’ve been wanting to get back to having a place where I can share my thoughts on a wider range of topics than “just” DevOps, although that will no doubt feature heavily here, too. So I’ve dug out the trusty LiveWriter (now a .Net Foundation Open Source project http://openlivewriter.org/ ) and linked it all up so I can blog on thoughts quickly and easily, probably predominately during my commutes from Greyshott to Cardiff, where DevOpsGuys is based.