Wednesday, October 27, 2010

SharePoint 2010 Replaceable Parameters

Replaceable parameters is one of the nicest new features implemented for Visual Studio 2010 Tools for SharePoint 2010. I won't go into elaborate detail because this feature is well documented here, here, here and here, just to name a few places. What I do want to do is point out a few things that may help you avoid frustrations.

1. In a standard SharePoint 2010 pr
oject, ASMX files do not get parsed. What this means is that you would have to hardcode your assembly information in these files. But, as MSDN has pointed out here you can edit your csproj to include new file extensions.




GREAT! Now we can have files other than ASPX, XML etc. Our ASMX files, amongst others, are now parsed and the tokens are replaced.

2. When using the following parameters:


  • $SharePoint.Type.<guid>.AssemblyQualifiedName$

  • $SharePoint.Type.<guid>.FullName$


always ensure that the GUID is lower case. I spent hours trying to figure out why this parameter wasn't being replaced. This problem came about because most people, including myself, just used the GUID Generator. The GUID Generator returns uppercase GUIDS. Here is something that will save you time. In Visual Studio you can select the inserted GUID, hit CTRL + U and voila, you now have a lower case GUID. For example

<Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>

<
Class>$SharePoint.Type.cd59ef5a-3bc8-409d-ab43-d0a166168f9d.FullName$</Class>

[Guid("cd59ef5a-3bc8-409d-ab43-d0a166168f9d")]

3. SNIPPETS are an amazing feature when used in conjunction with the replaceable parameters. If you go here, download and install the snippets package, you can now right click and insert any of the replaceable parameters directly into your files. No need to look up or remember any of them! SWEET!

I'm not saying anything I've said here is ground breaking, but I'm just trying to save you some time. For me, being able to insert a GUID, make it lower case and then use a snippet to insert the token into my file makes my SharePoint development easier.

1 comment:

Anonymous said...

" I spent hours trying to figure out why this parameter wasn't being replaced "

THANK YOU!