Dev Notes

Notes on Development with Microsoft Technologies

Replacement Tokens for VS2010 and SharePoint Projects

1 Comment


In a recent project, I needed to create an handler that returns an RSS feed for a custom web part. I added a new text file with the appropriate file extension and set the contents of the file to:

<%@ Assembly Name=&quot;Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c&quot; %>
<%@ Assembly Name=&quot;$SharePoint.Project.AssemblyFullName$&quot; %>
<%@ WebHandler Class=&quot;IdeaCenterWebParts.Code.SiteActivityRSSHandler&quot; %>

After compiling and deploying the project to SharePoint, each time I accessed the handler I received an error about an assembly not being found. To avoid delaying the project, I simply provided the full assembly name (IdeaCenterWebParts, Version=, Culture=neutral, PublicKeyToken=5e88564ecf55ef51) and went about my business.

I received some requests to change the project and to try to avoid versioning conflicts I updated my file version from to and then my error returned. This lead me down a path of discovery.


One of the nice things about developing in Visual Studio for SharePoint 2010 projects are replacement tokens provided in the project. First, tokens are replaced at the end of the packaging of the solution so it will only work with non-compiled files. This is great for features and other code depending on these tokens to be dynamically created. However, there are only a handful of files where tokens are searched and replaced. The default list includes many of the common ones that you would typically use in a project:

  • XML
  • ASCX
  • ASPX
  • Webpart
  • DWP

Notice, WCF Services Files (SVC), ASP.NET Handler Files (ASHX) and ASP.NET SOAP Web Services are not included in the list. This means the files will be ignored and the token will remain. I figured there has to be a way to resolve this so I read on further in the article on MSDN. According to this article, the simple way to fix the problem is to open the project file (.csproj/.vbproj) and edit the XML to include your additional targets. This is done on a project by project basis.

Simply add a line similar to the following to the first PropertyGroup:


Here’s my project’s first PropertyGroup node:

    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>

Now, if I change the version number or assembly name of the project my references stay up-to-date!


Author: Chris Quick

I have been a developer of web based solutions since early 2001 delivering solutions to a wide array of organizations using ASP, ASP.NET and SharePoint. I was introduced to SharePoint in 2003 when the consulting firm I worked for at the time introduced it into the workplace. I began working with MOSS 2007 as soon as Microsoft released the RTM version in November 2006. The platform was implemented at the organization I worked for in 2007 and went live in March of that year. I was tasked with the administration and ongoing development of the platform. I currently work as a SharePoint Architect with Artis Consulting, developing solutions for a wide variety of business problems. The goal of this blog is to share my discoveries developing solutions with SharePoint. I welcome your comments and feedback to any post -- and I welcome suggestions for future topics.

One thought on “Replacement Tokens for VS2010 and SharePoint Projects

  1. Pingback: Creating Site Pages containing List for SharePoint using Visual Studio | Ravi Ranjan Karn

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s