in SharePoint 2010

SharePoint 2010 Visual Studio Replaceable Parameters

This is one of the best features in the Visual Studio 2010 Tools for SharePoint 2010! You can use these replaceable parameters in your project files for SharePoint values. Visual Studio will replace them with actual values when packaging the solution.

This is very useful, especially in Elements file or .ascx page files.

Some Example Usages

For example, this is how I use for my delegate control:

<Control Id="AdditionalPageHead"
           ControlAssembly="$SharePoint.Project.AssemblyFullName$"
           ControlClass="$SharePoint.Type.15c18d58-bb1f-458e-b932-2223ca1f276a.FullName$" />

When packaging, the $SharePoint.Project.AssemblyFullName$ will get replaced to:

AssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=publickeytoken

And $SharePoint.Type.<guid>.FullName$ will get replaced to the appropriate class.

If you want to use the token the replace your class name, you need to add the Guid (System.Runtime.InteropServices) attribute:

Guid Attribute

When you add Event Receiver to your feature, VS2010 does exactly the same. After adding event receiver, navigate to your feature properties to find the tokens used:

Feature Properties

And if you add an Application Page or User Control, you can see it too:

Application Page

How to find if my token has been replaced properly?

If you want to check whether your tokens had been replaced properly:

1) Package your solution – Right click your Project | Select Package

2) In the Solution Explorer, click Show All Files

3) Expand pkgobj | Debug or Release | TokenReplaceFolder

pkgobj Folder

4) Open the appropriate files to find whether your tokens has been replaced

Write a Comment

Comment

Time limit is exhausted. Please reload the CAPTCHA.