22. July 2010 13:09
by Chaks
0 Comments
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:
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:
And if you add an Application Page or User Control, you can see it too:
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
4) Open the appropriate files to find whether your tokens has been replaced