Home
About Us
Contact Us
Advertise
Facebook
Twitter
RSS Feed
Printable version
Visual Studio replaceable parameters for SharePoint solutions
By Phil Jirsa
December 8, 2011 —
(Page 1 of 2)
If you’ve done any development on SharePoint 2010 using Visual Studio, you’ve probably noticed some files in your project that include strings like
$SharePoint.Project.AssemblyFullName$ or $SharePoint.Package.Name$
. These token strings are called Replaceable Parameters. When your SharePoint Solution (.wsp) is being packaged by Visual Studio, the packaging tool will search for and replace these tokens with values that are not known at design time.
Some of you probably remember doing this process manually with SharePoint 2007 projects. Build the solution; copy the DLL to the GAC; view properties of assembly in the GAC and copy PublicKeyToken; finally, create the assembly full-name string by hand and paste it back into a manifest file, etc. It was time-consuming and error-prone, though some third-party tools did help with this process.
Now, we can leverage Replaceable Parameters to avoid this process and do lots more. These parameters can be useful for single developer projects all the way to large projects using TFS with automated builds.
Let’s use an example to illustrate injecting a class name for an event receiver into a feature.
First, we need to create a new project in Visual Studio. Choose the “Empty SharePoint Project” template from the list.
Figure 1
Next, add an
Event Receiver
to the item to the project. I called mine EventReceiver1. For the event receiver settings, I chose list events and Document Library as my event source. To complete the wizard, choose the specific events that you’d like to implement handlers for and click
Finish
.
Figure 2
Figure 3
Visual Studio will now build a class to contain our handlers and a feature to provision the handler to a site. These items should now appear in Solution Explorer, and the class for our handlers will be open.
Figure 4
Figure 5
Expand the
EventReceiver1
element and open the
Elements.xml
file. This is where our feature is going to wire up the event handlers to our SharePoint environment.
Next Page
Pages
1
2
Share this link:
http://www.sptechweb.com/link/36178
Related Articles
Customizing SharePoint Online Using SharePoint Designer, Part 1
Once you get a handle on SharePoint Online, the question becomes: How can I modify it to suit my needs. First of two parts.
Visual Studio Update 2 targets SharePoint
IntelliTrace support and imprvoed load testing highlight this release
Bamboo Solutions releases Chart Plus R3.5 for SharePoint 2010
Bamboo Solutions has announced the release of Chart Plus R3.5 for SharePoint 2010