Including Codebehind Files in your WSP

Source (and copied from)  : Paul Willen

I really love the codeplex project “WSPBuilder
WSPBuilder makes life for a Sharepoint Developer a lot easier.
The last two weeks we were working on a solution to copy documents from one document library in a site to an other document library. I’ll blog about that later.
But the thing that bugged us that our codebehind page (.aspx.cs) wasn’t included in the solution which resulted in an error while opening the specific solution page.
We didn’t realise that WSPBuilder, by default, excludes these filetypes.
To change these settings you need to go to the Installation Folder of WSPBuilder. This can be found at “C:Program FilesWSPToolsWSPBuilderExtensions
There you will see a file named “WSPBuilder.exe.config”
Copy this file over to the folder where you see the 12-hive in your solution (The obj and bin folders are also in this folder).
Now you need to change the WSPBuilder.exe.config file. Open this file in Visual Studio or notepad and change the TraceLevel key to value=”5″
By changing this key you’ll receive more information what happens when building the WSP.
Move the line
<add key=”Includefiletypes” value=””> which can be found in the commented part right under the TraceLevel key
add the value “cs” for C# or “vb” for Visual Basic to this key. If you want to add multiple values make sure you seperate them with a comma.
The first part of WSPBuilder.exe.config should look like this:

<?xml version=1.0 encoding=utf-8 ?>
add key=BuildDDF value=false
add key=TraceLevel value=5
add key=Includefiletypes value=cs
Optional settings
You can set the arguments in this file or use them directly in the console.
All arguments has a defualt value. See wspbuilder -help

Save this file and now build the WSP like you normally should.
Now the codebehind file should be included into your WSP file.

To check if the codebehind file is truely included into the WSP file rename “yoursolution.wsp” to “” and doubleclick¬†“”.

There you can see all the files included into the project.

Leave a Reply

Your email address will not be published. Required fields are marked *