4 Dec 2015

Sharing Code Between SharePoint Solutions

I'm currently working on upgrading a large set of SharePoint Web Part solutions from SharePoint 2010 to SharePoint 2013. As part of this work, I have been identifying code that is common to several of the solutions (logging to the ULS, decoding Claims Based Authenticated usernames) and moving it to a single common utility DLL. I thought it would be useful to document how I have done this, and to share some lessons I've learnt along the way.


"NuGet is the package manager for the Microsoft development platform including .NET. " Taken from https://www.nuget.org

NuGet is the obvious choice for sharing a common assembly between multiple solutions. By simply adding this NuGet package (https://www.nuget.org/packages/CreateNewNuGetPackageFromProjectAfterEachBuild/) to the Visual Studio project I created for my common code, a .nupkg file was automatically created following each build.  I created a local (internal) package repository on a network share and added a post-build event to my project to push new .nupkg files to this location. Altogether, this took approximately an hour to add to my existing common utility project, and most of this was learning how to populate the NuGet package manifest.

I then added the local package source as a feed in Visual Studio (see https://docs.nuget.org/create/hosting-your-own-nuget-feeds for details), and installed the package in the various SharePoint solutions I was working on.  To ensure that I could track what version of the common utility DLL was installed, the assembly and resulting .nupkg file was versioned. As the upgrading of the solutions is ongoing, there will be a need to add additional common code to the utility assembly, and to ensure that all SharePoint solution are updated to the latest version.

Packaging and Deployment

My initial approach to package and deploy the common utility assembly was to add it as an additional assembly into the various SharePoint solution packages, (see https://msdn.microsoft.com/en-us/library/ee231595%28v=vs.120%29.aspx for details). This is the recommended approach from MSDN. It is also completely wrong.

The problem is that SharePoint packaging and deployment mechanism does not count the number of references that are made to shared assemblies used across multiple SharePoint solutions. This leads to an issue when a solution referencing the shared assembly is uninstalled, then the shared assembly is also uninstalled. This leads to the other solutions that reference the shared assembly being broken. This isn’t a new problem – it has been around since SharePoint 2010 (see http://lawrencecawood.com/2011/07/13/how-i-solved-the-problem-of-dlls-being-removed-during-wsp-uninstallation/).

In my specific case, the problem occurred when I deployed a SharePoint solution that included a new updated version of the common assembly. If I had deployed several solutions that referenced version of the Common.dll, and then deployed an upgraded solution that referenced version of the Common.dll, the version Common.dll was uninstalled as part of the deployment and version was installed instead. The new solution worked perfectly, but the other deployed solutions that still referenced version were broken. This lead to a sticky moment following one deployment to Production. Once I twigged what the issue was, I simply redeployed the most recent WSP of a solution containing the now missing version of the common assembly.

Deployment Redux

It was clear that continuing to deploy the common assembly as an additional assembly in he SharePoint solution package wasn't an option. While it was an intermittent issue, only occurring when deploying an updated version of the common assembly, it was still a problem that could lead to unnecessary downtime. So, what other options for sharing common code were there?

After a bit of research, I came up with the following options:

  1. Deploy each new version of the Common.dll as a separate solution, deployed separately. The WSP for each version would include the version number in the name (i.e. Common.V1.0.0.1.dll) and would ned to have unique solution GUIDs for deployment. This would allow the referenced assembly to be removed from the package for web parts that reference it, so it would not be removed when deploying newer versions.
  2. Create a separate solution package to deploy the various versions of the common assembly, and several other 3rd party DLLs. This would isolate the deployment of the common assembly from the deployment of the various solutions that reference it. Obviously, if a solution referencing a new (not previously deployed) version of the common assembly is now deployed, the new solution containing the common assemblies must be updated to include the new version and also deployed.
  3. Remove versioning entirely. Simply use V1.0.0.0 of the common assembly. Instead of deleting methods, or changing method parameters, future changes would require overload existing methods and using the [Deprecated] and [Obsolete] attributes to indicate methods that have been superseded in the latest 'version' of the assembly.
  4. Merge the common assembly into a single assembly for each separate web part solution using ILMerge. This allows for the versioned common assembly be used, and results in a single DLL for each solution, avoiding additional assemblies and versioning in SharePoint altogether.

Clearly, using ILMerge was the best way forward. And it turned out to be very easy to implement with the existing solutions. The steps are:

  1. Install the Nuget package https://www.nuget.org/packages/MSBuild.ILMerge.Task/1.0.3-rc2 (it will also install a NuGet package for ILMERGE as a dependency).
  2. Clean and rebuild the solution in Visual Studio.
The resulting DLL takes the name of the parent solution, and when you check the assembly using ILSpy, it includes the namespace of the common utility code as well as that of the parent solution. Note, if you are building an assembly for a SharePoint solution, all the child assemblies must be signed.  The additional assemblies to be combined with the primary DLL must also have the Copy Local property set to TRUE (this is the default when using NuGet packages).

Hopefully, the above is of some use if you're looking for a solution to share code across multiple SharePoint solutions.

6 Oct 2015

The End of the Jobs Feed

Almost 5 years ago, I used Yahoo Pipes to put together a handy RSS feed aggregating jobs from various NI recruitment sites for software developers. Unfortunately, at the end of September, Yahoo Pipes shut down, and my jobs feed is no longer working. If you have been using the RSS feed, please accept my apologies. I completely missed the end of life announcement for Yahoo Pipes (I’ve had other things on my mind this summer).  At the minute, I have no plans (or time) to put together a replacement. If anyone is aware of any alternatives for the job feed, please let us know through the comments.  Thanks.

16 Apr 2015

Five Minute Fitness Test

In a previous post, I mentioned one of my goals for this year was to achieve a score of 250+ in the Five Minute Fitness Test. In this post, I’m going to describe the fitness test I’ll be using.

I came across the test in The Para Fitness Guide by Sam McGrath, the former Head of Parachute Training and Selection. If you’re interested in bodyweight training and getting in shape, I can’t recommend this book highly enough.  I’m particularly like this test as requires no equipment and can be done anywhere. And, as it depends on bodyweight only, it is good way to compare your relative muscular endurance over time.

The test is as follows:

  • Press-ups – as many reps in 60 seconds
  • Rest for 10 seconds
  • Sit-ups (feet secured) - as many reps in 60 seconds
  • Rest for 10 seconds
  • Star Jumps - as many reps in 60 seconds
  • Rest for 10 seconds
  • Squat Thrusts – as many Reps in 60 seconds
  • Rest for 10 seconds
  • Burpees – as many reps in 60 seconds

In the book, the following fitness scale is used based on your combined score for the above exercises:

Fitness Level Basic Recruit Soldier Paratrooper
Score 0-99 100-199 200-264 265+

So far, my best score for the test is 194, so I still have some work to do to break 250+. 

Fair warning, this test is a lot tougher than it sounds. I strongly recommend taking it easy the first time you try it. I generally do this test once a week.  But I recently came across another Five Minute Fitness Test, and I have started alternating between the two for variety.

14 Apr 2015

The Software Developer’s Guide to Interviews

I’ve just completed a round of interviews for developer roles, and thought it would be useful to post some thoughts on the process. In particular, I wanted to document what the interview can tell you, the interviewee, about the role and the company you are applying to. There are plenty of guides telling you how to prepare for an interview. I don’t know of any that tell you how to review an interview and use that information to rate the different positions and companies you’re applying to. I suspect most people just go with their gut instinct, which is usually right, but doing a systematic review may help you realise why you prefer one job offer over another.

TL;DR Version

How a company behaves during the recruitment process is a good indicator of its internal culture and what it would be like to work there.

The Ideal Recruitment Process

From my experience of both interviewing and attending interviews for developer roles, a good recruitment process will follow most of these steps:

  • Write the Job Specification - The job advertisement will be based on the job specification for the role. This should specify both the essential and desirable skills and experience that applicants should have.  If possible, this should be initially be developed by senior team members for the new role. In my experience however, the larger the company, the less influence the team will have on the job specification. If you are really unlucky, the job specification will simply be a generic description for that role in the company hierarchy, and will have no information on the work you will actually be doing.
  • Form an Interview Panel - At a minimum, this should consist of a manager (preferably the manager the new hire will report directly to) and two technical interviewers (as it is harder to bullshit two people at the same time!). I personally prefer to have a member of HR also present – this helps keep the manager honest and prevent them stretching the truth when attempting to attract candidates. This is a particular issue for benefits like remote working that may not be explicitly set out in a contract. In general, the larger the interview panel, the more seriously a company takes recruitment.  A manager may also wear a technical hat, so you may only have 3 people in the panel. The interview panel will typically be responsible for setting the interview questions and defining a criteria for scoring answers.
  • CV Screening - The interview panel review the submitted CVs to the job specification and draw up a long list for interviews. This may happen after a closing date for applications, or as applications are received.
  • Telephone Screening - This is generally a 15-20 minute call from HR to discuss the application, and confirm that the applicant meets the role requirements.
  • Technical Screening – This can be a telephone interview with a senior developer discussing the interviewee’s technical background and asking a number of set technical questions.Alternatively, this may be an online programming assessment such as Codility or an onsite technical test as part of the actual interview.  The aim of the technical screen is to confirm that the applicant does have the necessary skills and experience required for the role.
  • Interview - Obviously this should be an interview with the full interview panel, who each assess the interviewee on a number of pre-set questions for which the panel have identified key answer criteria.  Typically, this would include questions on the applicant’s CV and past experience, questions specific to the role requirements and also soft skills, and then a number of technical questions.  The technical questions should cover more than just the basic job requirements – the questions should cover a range of technical levels and start at core, fundamental concepts and build to advanced topics.  The idea is to identify exactly how technically competent the interviewee is.  These questions should stretch every applicant to some extent, and will be long form in format, to allow the interview panel to force the applicant to to deep dives on specific topics. Additionally:
    • The interview described above will typically take 2 hours to complete.
    • For a developer role, this should always include some form of live coding. This is regardless of whether a technical screen was done previously or not – I’ve came across  too many developers who can BS their way through telephone screens and interviews but who are unable to code.
    • At the end, the panel leader should tell the interviewee how and when they hear the outcome of the interview.
  • Post Interview Review - The interview panel reviews each applicant immediately following the interview, and scores them using the agreed scoring criteria.  The panel’s aggregate score for each interviewee is used to decide who gets the job.
  • Job Offer – The post is offered to the successful applicant and their references are contacted.
  • Inform all Applicants – Once the job has been accepted and the references confirmed, HR should respond to all the unsuccessful applicants. This should be within the time period specified at the end of the interview. Ideally, this shouldn’t be longer than a week, but depending on salary negotiations and references, can take longer. For an automated recruitment process, this may be an online status on the candidate’s application and/or an automated email. Preferably, it should a personal response from HR, either by email or, rarely these days, a letter. 

Based on the above outline, you can see that the recruitment process is a major investment by a company over several months, with no guarantee of a successful outcome (i.e. finding a suitably experienced applicant who will accept the position within the given salary limits).  Your interview may only last an hour or two, but by comparing your experience of a company’s recruitment process to the above, you can get a sense of how they value employees, and what it would be like to work there.

Your Interview Review

OK, so you were lucky enough to be shortlisted, and you’ve just had your interview.  Sorry, but now you going to take 10 minutes to review the interview and your experience with the company.  I typically write these review notes at the end of a document I create for each job application, detailing the job requirements, company background and any questions to ask at the interview. I then update the document with any relevant notes each time I have an interview or call with the company, so I can track exactly how the application is progressing.

The points you need to consider are:

  • How has the company communicated with you since you applied to the position?  Has it been a single person communicating to you, or several, or an automated process? How did you find it – personal or completely anonymous?  How the company treats you as an applicant will typically reflect how it will treat you as an employee.
  • Was there a telephone screening interview with HR?  This is not essential, but is best practice. If it happened, it is confirmation that the company has a defined interview process.  What questions were asked?  You obviously recorded the questions, and any useful information, to prepare for your interview.  From the questions asked, you can also get a good idea of what the panel will focus on the interview, and get a better idea of the work you will actually be doing.
  • How were you tested technically?  Were you sufficiently tested? This isn’t a minor point.  If you were not tested on your knowledge and experience, then the people you will be working with will not have been tested either.  That means you will likely be working alongside some developers who don’t have the skills or experience for the job they are doing.  You might be the person who ends up carrying them.
  • Did you have to write code as part of your interview process?  If not, this is a major failing. If the company doesn’t know if you can code or not, what is the point hiring you?
  • How large was the interview panel?  This is most visible way of assessing how important a company views recruiting developers.  I would be very wary of accepting any offer from a company with less than 3 people on the interview panel, regardless of the size of the company.   Even a one person start-up should be willing to hire HR and technical consultants to have a proper interview panel. If they don’t, they haven’t a clue and you shouldn’t waste your time with them.
  • The interview itself:
    • Were the questions asked relevant to the work you believe you will be doing? 
    • Did the questions asked match the advertised job?  If it doesn’t, it is likely that the job advertised won’t be the job you will actually be doing. This means that the team doesn’t have much influence on other departments in the company – this may reflect that the team you will be joining is low down in the company’s hierarchy and priorities.
    • The interviewer’s personality and  behaviour. Were you treated with respect?  Would you like to work with these people?  Remember, in an interview, people are on their best behaviour on both sides of the table.  If you come out of an interview thinking that one of the interviewers was a pain, then they will be most likely be a complete bastard to work with. You need to trust your gut instinct about people.
  • How was the outcome communicated to you?  Was it done within the time frame set out by the interview panel?  I’ve known companies to pompously rant on about interviewees not attending interviews. The same companies will then completely ignore all unsuccessful applicants once the post is filled – this is extremely disrespectful behaviour.  If you’ve applied for a position, you will have spent several hours updating your CV, writing a custom covering letter, as well as preparing for and attending interviews.  At the very least, you deserve an email informing you that you have been unsuccessful.

Once you have completed the review, you will have a better idea of the company you may be working with. Obviously, this is only directly useful if you are offered the post, and if you have the option to refuse the offer.  Fortunately, experienced developers typically do receive multiple offers, and having an idea of the company’s culture can help you decide which offer is the best for you.  Also, even if you aren’t successful, it informs you on whether this is a company you want to apply to again in the future.

Case Study: Kana

My recent application with Kana in Belfast was one of the worst recruitment experiences that I ever had. I thought it would be worthwhile to share some notes I made after my interviews with Kana:

  • There was a brief telephone screening interview with HR, consisting of some standard questions about my CV and past experience.
  • At the first interview, I was interviewed by the team leader and a senior developer from the team I would be joining if successful. There was no one from HR present. It was a standard interview walking through my past experience and testing my technical ability. Overall it lasted around 90 minutes and was reasonably thorough. There was no coding test or any technical screening aside from the questions asked during the interview. There were a number of questions asked around my commute (I live 50 miles away from where the company is located) and my availability to work late that suggested that this is a team under significant pressure. The actual job did sound interesting (a nice mix of technologies,with a mix of both front- and back-end development), but there were a few red flags, like the focus on being able to work late.  The team leader also had a habit of talking over the senior developer that suggested they might be difficult to work with. At the end of the interview I was told I would get feedback about the interview in 2 weeks.
  • At the second interview (just under 2 weeks later), I was interviewed by the VP for Development and the Principal Architect.  It lasted approximately 60 minutes.  They asked almost exactly the same questions as had been asked at the first interview. I was also told that the role would involve a significant amount of work with Clojure, and relatively little with .NET, despite the role being advertised as a .NET Developer role with no mention of Clojure in the job description. I found the VP to be very brisk in manner, and the Architect while friendly, came across as extremely bored. Obviously, there were a number of issues here:
    • Why were the same questions being asked again?  Did the second interview panel either not speak to the first, or do they not trust their opinion?  Either way, there is a communication issue here.
    • Again, same focus on my commute and on being able to work long hours.
    • The second panel’s interpretation of the role (more Clojure, less .NET) differed from that of the first interview panel and job advertised.  Who is right?

At the end of the second interview, I was told I would be informed within a week if I had been successful or not. Both interviews were held in January 2015. It is now over 2 months later and I haven’t heard anything from Kana, despite sending a polite email asking for some feedback a few weeks ago.

It will probably come as no surprise, but I wouldn’t recommend applying to Kana based on my experience. Winking smile

What has your experience been in interviews?  Do you have your own way of reviewing job applications?  Please share in the comments below.

Thanks to Toby Osbourn for reading a draft of this post. You should read Toby’s blog Development Thoughts where he posts great articles on Ruby and web development.

4 Feb 2015

Goals for 2015

2014 was a pretty miserable year for me. I lost my mother due to illness. I spent a large part of the year not working, and I was quite unfit, as I wasn’t running due to a recurring Achilles injury.  I well aware that there are far too many people who are lot worse off, and that I am actually very privileged, but I can’t help but look back at last year with a lot of regret.

2015 will be a much better year.  I am planning to marry my beautiful girlfriend, Mei, in September.  I’ve just started a new role that I’m very excited about, and I’m now starting to run seriously again, after a lot of physiotherapy and exercise to rehabilitate my ankle. 

These are my goals for the year ahead:

  1. To start running again!! Specifically, I want to:
    1. Run 80 miles per month by June.  I’m currently running around 25-30 miles per month, a very low mileage.
    2. Run every Parkrun in NI by the end of the year,  There are currently 19 Parkruns setup in Northern Ireland; I’ll be amazed if there isn’t 20+ by the end of the year.
  2. Get physically fit again!!  Starting to run again is one thing, but I also want to improve my overall fitness.  This will mean:
    1. Achieve a score of 250+ in the Five Minute Fitness Challenge (blog post to come)
    2. To weigh 70Kg at under 15% body fat by December 2015
  3. To develop a non-trivial side project using JavaScript. 
  4. Marry my girlfriend Mei. The most important thing for the year ahead will be my marriage to Mei in September. 

Mei & I

6 Jan 2015

Online Coding Tests with Codility

I spent several hours today on an online coding test for an employer.  This isn’t my first test using Codility. Not only have I done several of the tests before, but I’ve actually recommended they be used in a previous employer, when I was involved in interviewing, So I thought I share some thoughts around approaching these type of tests.  Before I start, please note – I won’t be posting any solutions to the tests I’ve done.  But feel free to try this useful link - http://bit.ly/1wSuukg. Winking smile

Codility is an online site that allows employers to set online coding tests for prospective developers.  It is effectively an automated screen to ensure that prospective developers have the necessary programming skills for the role. As it can take up a lot of time to arrange telephone calls for technical screening interviews, or onsite technical tests as part of the interview, Codility or the alternative CodeEval, can help save a lot of time.  Obviously, even when using something like Codility, you would still want to have a significant technical element to any subsequent interview.  Tools like Codility are an aid to the interview, but they certainly doesn’t replace it.

The actual test is sent to via an email with a personalized link to Codility.  Typically the link will only be valid for a set period (i.e. 24 hours).  On clicking the link, you are taken to landing page where you can choose to start the test, practice with a demo test or come back later.

Once the online IDE loads, you will be taken through a tour of the IDE features.

Some features in the IDE to be aware of:

  • Problem description (left hand panel).
  • Custom test cases (bottom of the left hand panel).  This allows you to define test cases for your solution, based on the problem description.
  • Code Editor (top right hand panel).
  • Countdown timer  (top right hand corner). Note, each task will typically take around 30-40 minutes.
  • Select the language to code your solution (top right hand corner). Note, this can be limited by the company setting the test.
  • Various buttons to run and submit your solution
  • Console window (bottom right hand panel).  This will display the results of your code solution, including from your test cases.

Note, once the test starts, you can’t stop – the tests are time limited. 

The solutions require you to implement an algorithm described in the problem description. You may be asked to develop a solution with regard to performance, as expressed in the Big O Notation.  Check out this primer if it has been a while since you covered Big O notation!  Note, I have also seen a task that required you to correct an existing buggy implementation of an algorithm, so you may not always be starting a solution from scratch.

Now for my thoughts and tips for taking the test.

  1. Practice using the demo test and examples on the Codility blog.
  2. Refresh your knowledge on algorithms (i.e. sorting algorithm such as BubbleSort, or search algorithms such as BinarySearch), and specifically on Big O Notation.
  3. Use the problem description to define and breakdown your solution.  I typically break the problem statement into single sentences and use this as comments to outline and stub out my code solution.  Obvious, but it is easy to get flustered when taking one of these test for the first time.
  4. Use your usual IDE to develop your solution. The Codility site wants you to develop your code in their online IDE – I found this a real pain to use, and slow at times. My advice is to create a console application to host your solution code, and to develop in Visual Studio (or your IDE/code editor of choice) on your local machine. This offers a few advantages:
    • It is a familiar coding environment that you already know.  The Codility IDE is OK, but it has a few quirks.  For example, I found the custom test cases feature a bit of a pain to use.  There is no learning curve required when you are using your usual IDE editor.
    • You can benefit from automatic error highlighting and faster feedback on compilation errors.  The Codility IDE requires you to hit the Run button and then to read and decipher any errors in the console panel.  Your own IDE will typically give you more information about errors, and give it a lot faster.  This is important, as time is limited!
    • You can make use of a proper unit testing framework, such as NUnit. As noted above, the test case feature in Codility is clunky, and limits you to only 5 test cases.  Forget that, use NUnit and define as many tests as you need.

I created my test console application when I was going through the demo test, to ensure it was working correctly prior to actually starting the test. For the demo (and also the test tasks), I simply copied the stub method to be developed from the Codility IDE into my test console application, and developed it there.  When I had successfully coded and tested it in Visual Studio, I then copied the completed method into the Codility IDE, and then re-tested before submitting.  Once the solution is submitted, you can modify it or resubmit.

When submitted, the solution is analysed by Codility, and a detailed breakdown of your solution is available to the employer who set the test.  You can check out an example here.  Your result obviously determines whether or not you get called for interview.

Previously, I’ve done quite well in the Codility tests, and actually enjoyed taking them.  They are a bit like code katas. Today’s test, however, was a disaster.   There were 3 tasks to be completed, instead of the usual 1, so that the total time for the test was 2 hours.  I took far too long on the first task, which meant I had to rush on the second task.  After spending some time on the second task,  I ended up having barely anytime at all for the last test, so I doubt I’ll get called back. Entirely my own fault.  Interestingly, the second task required the correction of a buggy implementation of an algorithm. I suspect this was deliberately added by the employer as the role I was applying for would involve dealing with legacy code.

Despite today’s cock-up, I still like the Codility tests, and would certainly like to see them more widely used – they’re a lot better than the usual FizzBuzz whiteboard exercise!


Despite the problems I had with the Codility test, I was called for an interview. I was offered a job, but not the position I had actually applied for.  After some deliberation, I declined as I didn’t feel the offered job would push me enough.  But I was very happy to be given the opportunity!

2 Jan 2015

A Base .NET Console Application

I often use use console applications to put together proof of concepts and demos.  So I was very interested in this base console application from John Atten. However, while John’s console template was built to be interactive, I wanted a simpler base console that I could use as a starting point for any project. 

The source code for the application can be found on GitHub

At the minute, the solution is nothing more than a skeleton application with logging, error handling and strongly typed configuration settings provided.  It also makes use of a command line parsing library to allow easy addition of new commands. 

This is just an initial draft of the base console application. As I’m working on a couple of projects that will make use of this base console application, I’ll update the solution with any improvements I can think of in the next few weeks. I'm also happy to take pull requests, suggestions, and ideas for ways it can be extended.

Also, when developing the solution, I came across a minor issue with the BizArk toolkit, used for the command line parsing. I submitted a patch for the issue (that can be seen here), following these instructions from Scott Hanselman. My first patch to an open source solution!