Can’t Find Visual Studio 2012 Project Templates For SharePoint 2013

For future reference, this post was written at the time that SharePoint 2013 was in Technical Preview.

While working with the SharePoint 2013 technical preview, you may find yourself actually want to develop something :) I wanted to explore developing a workflow for my current client whom is on the RAD MSFT program for SharePoint 2013, so spun up the preview. So, you might be installing Visual Studio 2012 and then install SharePoint 2013, and expect there to be some relevant project templates available for you to develop against. Too bad, no go.

To get em in there, go to here:

Navigate to the Tools section. You will find them there. Shut down Visual Studio, install, you should be good to go. Unless you are trying to use the WWF 4 toolbox items. To get that with targeting to .NET 4.5 add Workflow as a new item, but DO NOT use the Sequential or State Machine workflow since it will go to the .NET 3.0 stack.


Setup Has Detected Previous Versions Of SharePoint – SharePoint 2013

But there are no versions on the machine you are using?

Lots of folks have been pinging me about this on freshy Windows Server 2008 R2 machines, using the eval copy that was released for testing a few days ago for SharePoint 2013 preview. I was able to replicate the problem, and there is a way to get around it. Don’t use the links on PSConfig, they all still point to 2010 material :)

Long story short, few things to check.

  1. Is there adequate disk space?
  2. Have you installed SP1 for Windows Server 2008?
  3. Confirm that all pre-reqs have run successfully.

All that look good? It’s in all probability actually not a freshy machine and there are still some files left over a 2010 installation. Check this registry path:

HKLM\Software\Microsoft\Shared Tools\Web Server Extensions\14.0

Delete all the folders under it, then try the installation again.


Building A Simple SharePoint 2007 / WSS v3 WebPart

First Steps In Creating A Simple SharePoint 2007 (MOSS) / WSSv3 WebPart

There are several differences that exist between the ways that WebParts were written in the SharePoint 2003 framework as opposed to the SharePoint 2007 (MOSS) framework that dramatically increases the functionality that is available to the developer. As written about in previous articles, there has been a dramatic shift in how WebParts are structured within the 2003 framework and the 2007 framework.

What Has Changed?

The way that WebParts are programmed in WSS 3.0 has changed drastically, however the benefits of programming WebPart instead of standalone .NET application remains the same. One of the most important things that is covered with the introduction of WSS 3.0 is the legacy style of creating WebParts (although both inherit from the WebPart class, in 3.0 this class is located in System.Web.UI.WebControls.WebParts namespace, and in WSS 2.0 this base class was located in the Microsoft.SharePoint.Pages namespace) is still maintained, and although the environment may have changed, programmatic efforts will not have been wasted. Since the new WebPart framework is based on the ASP.NET 2.0 framework, in order to maintain functionality and rendering capability there has been changes to the Microsoft.SharePoint.dll, referenced heavily when creating new WebPart projects.

WebPartManager Control

The most important concept to grasp in relation to developing ASP.NET 2.0 WebParts is the WebPartManager control (Note: this is in relation to ASP.NET 2.0 WebPart development, we will touch on the WSS 3.0 control responsibility for rendering shortly). This control serves a very important purpose in relation to the new technology of WebParts, mostly tailored around the serialization and de-serialization of WebPart related data since this data is transported from the database.

Starting to Create the WebPart

The first step in creating a new WebPart is to open the Visual Studio 2005 client (you can also use notepad if you wish to compile with the CSC command). You are then going to create a new project. When the project selection screen comes up, choose a class library, and then in language selection box choose either C# .NET or Visual Basic .NET, depending on yours or your client preferences. Name your project Hello World. When building SharePoint 2007 WebParts, and since it is common for the WebParts to exist within the GAC, you must modify your assemblyinfo.cs (or.vb) file in order to build the project with a signed assembly. This can also be done through the Visual Studio 2005 command prompt using the sn.exe command.

Open the class file that is located in your Visual Studio project. In this file, you will see at the top using statements (for the remainder of this article the examples will be provided in C#, but for brevity it will be imports statements or VB.NET). Through the use of adding references to this portion, will gain access to different options to inherit portions of code that would otherwise require several re-writes of code that is already placed into the framework.

Adding the Necessary References

The first reference that you will see in the default class library is the System. We will have to add other using statements in order to properly build other WebParts. Firstly, ensure the following references are made:

  • System
  • System.Web.UI
  • System.Web.UI.WebControls.WebParts

This should look like the following when added to your C# class file, located at the top before any other code (again, this should read imports …. if you are using VB.NET):


using System.Web;

using System.Web.UI;



Following, as explained before, we will have to change some of the inheritance so that our WebPart class will inherit out of the System.Web.UI.WebControls.WebParts namespace. Our class is called HelloWebPart, therefore we will have to create this inheritance by placing the following syntax.

Exposing SharePoint Specific Assets

For exposing certain SharePoint specific information and objects, there will have to be other references added to the project file. For the context of a Hello World WebPart, we are just facing text out of a WebPart, which doesn’t require access to the SharePoint object model, since in aggregate this is considered just an ASP.NET 2.0 WebPart. If for example, we wanted to query data out of a SharePoint list, we would have to add a reference to the Microsoft.SharePoint.dll, and then write some custom code to query the actual list. In order to setup access to the lists, you would have to first get the content of the current site as demonstrated below:


SPWeb HelloWorldTestSite = SPContext.Current.Web;


Then establish a reference to the list that we wish to query:


SPList Hellos = HelloWorldTestSite.Lists[HelloList];


In order to get all the items, there would have to be an enumeration set that would query through all of the objects of the list following:


foreach (SPlistitem Hellos in HelloList);

//Place your query logic here


Afterwards, you could massage the data as necessary and configure your display programmatically depending on your project requirements.

The Actual Hello World Code

Afterwards, to get our WebPart to render out some simple text, we will have to create some code that will parse out our message. It should look like the following when complete:


using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls.WebParts;

namespace helloworld {

public class helloworld : WebPart {

protected override void RenderContents(HtmlTextWriter writer) {

writer.Write (Hello World):





By placing the above code, you will get a simple SharePoint WebPart that when deployed will place the text Hello World within the WebPart.

Once built, you will get a simple assembly (or binary depending on semantics used within your organization), that can deployed to a SharePoint server pending some further modifications.

Deploying the WebPart for Use With Your Portal

There are two main locations where you can place a WebPart so that you can expose it to your users within your portal. The two places where a WebPart can be placed are:

  • GAC (Global Assembly Cache)
  • /bin directory of your SharePoint instance

For some organizations, placing a WebPart assembly within the GAC is not acceptable, since assemblies placed in this directory are run with full trust, and therefore not subject to several aspects of CAS (Code Access Security), so for the sake of this article we will deploy the WebPart to the local bin of the SharePoint site.

By default, your site collection will place relevant files for your SharePoint instance into your inetpub/wwwroot directory, where there is also a bin folder located, therefore the deployment path is inetput/wwwroot/bin for our SharePoint WebPart.

We can modify the path for where our WebPart is going to be deployed by going to the properties of the project (right click on the top level solution file from within Visual Studio.NET 2005 and select properties from the fly-out), where there are a great many other options outside of the deployment path, including setting the strong key that we are going to use. Under the build shuttle, under the output path, you can change the path to your SharePoint bin directory by placing the path C:\inetput\wwwroot\bin, where the final build will be placed.

Following, and similar to the architecture of SharePoint 2003, all WebPart have to have a safe control entry within the portal web.config in order to run correctly. This is an excellent feature since if there is a problematic WebPart that exist within your environment it is simple to switch it off in order to take it out of the entire environment until a remedy is implemented making it safe again for you to run.

Getting the WebPart to Appear On The Page

The steps in order to get the WebPart on your arbitrary SharePoint page are pretty straightforward. Navigate to the site actions menu on your site and go to the WebPart gallery. Select New which will allow you to add the newly deployed WebPart by selecting the checkbox next to your newly deployed project. Lastly, select the Populate Gallery option in order to deploy the WebPart for use within the portal.

Following, when you edit a page, you will be able to select the WebPart from the WebPart selection dialog through a variety of mechanisms including SharePoint designer and the GUI.