Monday, May 12, 2014

SharePoint 2010: Roll-out files with a solution in C#

Usually I don't tend to code as much as I do right now, which of course means that I'm a bit rusty. So naturally this one freaked me out. How do I deploy files, like JavaScript, CSS, with a solution. Of course I could just copy all the files in afterwards, but I wanted to have a slick solution with just a click of a button.

I ended up using Modules. Click on your project, add a new item and search for "Module".
Now place the files you need in this Module and open the Elements.xml. It will be automatically filled with the files from the Module. But maybe you want to store them in a differen library.
So heres the content of the Elements.xml:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="NameOfModule" Url="TargetLibrary">
<File Path="PathWithinTheModule" Url="TargetFolderWithinTheLibrary" Type="GhostableInLibrary" />
</Module>
</Elements>

I will come back to this post and add a couple of comments, but feel free to comment if you need help with this. Also I will add a couple of screenshots on how to add a module.

No comments:

Post a Comment