Basic setup of SharePoint Visual Studio project

Now, anyone who knows me will tell you that I am a big fan of doing things the hard way. Let me rephrase that. I like learning things the hard way. I’d rather hand build a .cab-file once and know how it’s done than to use some fancy tool that never teaches you anything but just gets the job sort of done. I’d love to sit around and discuss that all day, but I won’t. Instead I will show you how to do the basic setup of a blank solution in Visual studio so that you can start developing. If you’re really good and paying attention I will share with you my preferences on tools for doing this a bit faster at the end of the article.

Another very good reason for writing this article is that I do write a lot of other articles. Rather than explaining every time how to setup and how to deploy I can just refer people here. So, if you are lead here by another article, welcome, and don’t forget to go back to the original article after you are done.

Initial setup

Step 1: Start a blank Visual Studio solution with a Class library type.

Why a class library? Well, it seems the simplest. Start from scratch and you get all the control in the world.

step-1

Step 2: Delete the default Class1.cs file.

You wont need it for any of my articles. Or just rename it to whatever you want if you so desire, you still wont need it for any of my articles.

step-2

Step 3: Add a key-file to sign the assembly and create a strong name.

Go to the menu, in Project->[Your project name] properties and find the Signing tab. On the bottom section, click the checkbox called Sign the assembly.

step-3a

The drop-down box will be enabled and you can select New which in turn opens a new dialog. Type any name, create a password if you like and click Ok.

step-3b

Step 4: Build.

From the menu, click Build->Build solution. You’ll get a nice, strongly named dll which you will deploy somehow. We’ll get to that. No screenshots, it is one menu item click for crying out loud!

 

Deployment

Now, at this point you basically have what you need to start developing. However, at some point you will want to deploy your dll. While you are developing you will likely want to deploy several times as well. Because of this, automating deployment into the Global Assembly Cache (GAC) will save you some time.

Step 5: Automate deployment to GAC

In the Project->[Your project name] properties page you also, in addition to the Signing tab, have a Build actions tab. On that tab there is a field called Post build event command line. Paste the following into that field:

"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" /i "$(TargetPath)" /f

This just installs the dll into your GAC every time you hit Build.

step-5

 

From here on out you will go in any number of directions, which is why I won’t guide you further. Note that this process is rather generic, not SharePoint specific.

Bonus for attentive readers

As promised, since you have been paying attention, and if you haven’t, then shame on you, I will share with you my preferred way of setting up my SharePoint development solution. The trick is, I don’t. I use a tool to do all that for me. The name of the tool is WSPBuilder, created and made freely available at CodePlex by Carsten Keutmann. You can get it here: http://codeplex.com/wspbuilder.

With the latest release, WSPBuilder integrates into Visual Studio and gives you a couple of new solution templates.

bonus-1

These templates take care of the groundwork for you when you are developing SharePoint features. The WSPBuilder Project template creates a random keyfile and signs your assembly, creates a 12-folder for you to deploy your SharePoint content to the 12-hive, but even more important is the item templates and the functionality additions that WSPBuilder provides.

When you right-click your project to add a new item you get a whole range of often created SharePoint features.

bonus-2

Adding one of these sets up everything you need, more or less, to implement the feature. All those boring tasks like finding the strong name, putting it where it is supposed to go, etc.

Even better, in a WSP-builder project you get an extra item on your content menu when you right-click the Project in the solution explorer. That menu gives you instant access to creating the WSP-file, deploying, upgrading, and uninstalling you solution, it allows you to quickly recycle the Application pools so you updates are reload and it can, by the touch of a button, attach the debugger to the worker process, allowing you to debug your custom code really easily.

bonus-3

All the tedious work is automated!

I have no idea why mr. Keutmann did not charge for his excellent solution, but I would like, hereby, to express my deepest thank-you’s to him for letting everyone share this wonderful tool. By the way, he is also the author of the equally fantastic SharePoint Manager 2007, which he also lets everyone have for free: http://www.codeplex.com/spm.

Give the man free sex and beer for the rest of his life!

Found this article valuable? Want to show your appreciation? Here are some options:

a) Click on the banners anywhere on the site to visit my blog's sponsors. They are all hand-picked and are selected based on providing great products and services to the SharePoint community.

b) Donate Bitcoins! I love Bitcoins, and you can donate if you'd like by clicking the button below.

c) Spread the word! Below, you should find links to sharing this article on your favorite social media sites. I'm an attention junkie, so sharing is caring in my book!

Pin It

Published by

Bjørn Furuknap

I previously did SharePoint. These days, I try new things to see where I can find the passion. If you have great ideas, cool projects, or is in general an awesome person, get in touch and we might find out together.

Leave a Reply

Your email address will not be published.