Unknown's avatar

Posts by Simon Doy

I am an avid SharePoint enthusiast who works as an Independent SharePoint Consultant based in Leeds, United Kingdom. I am one of the organisers of the Yorkshire SharePoint User Group in the United Kingdom. I have been designing and building SharePoint solutions since 2006.

Building WSP Solution out of Multiple Visual Studio Projects


>

Introduction
Recently I have been building a reasonable sized SharePoint solution which is using multiple Visual Studio projects. Using the excellent WSPBuilder by Carlos Keutmann, the SharePoint content can be packaged up build individual solution files.
WSP Builder
Ok so as with these things there have been a few hacks to ensure that WSPBuilder does the right thing when building the package. Before I start I should explain how to use WSPBuilder, basically what you do is define the structure of the SharePoint 12 Hive in your project. So you create one folder called 12 and then create sub folders which mimics the SharePoint 12 Hive structure.
So under the 12 folder you would add the appropriate sub folders for your solution :-
TEMPLATESTEMPLATES\LAYOUTS\[YourAppFolder]TEMPLATES\IMAGES\[YourAppFolder]TEMPLATES\FEATURESTEMPLATES\SITETEMPLATES\YOURSITEDEFFOLDER.....
To add assemblies to your solution you create a GAC folder and an 80 folder at the same level as the 12 Folder.
To add an assembly into the GAC put the assembly in the GAC folder. To add an assembly into the web application bin folder put the assembly in the 80 folder.
The Problem
So far so good but when you have multiple projects building multiple assemblies, it is difficult to organise the files so that WSP Builder can build the solution correctly.
This is made worse when you have a project that builds an assembly which is then used by another of the projects.
To explain this if we have two projects, Project A and Project B. Project A builds assembly ProjectA.dll and Project B builds ProjectB.dll, Project B uses Project A.
When Project B is built it relies on the Project A dll and the assembly is copied into Project B’s build directory.
Now if you wanted to package up the solution using WSP Builder, you can run WSP Builder as part of the post build event by running “c:\program files\wspbuilder\wspbuilder.exe”. However if the assemblies, ProjectA.dll and ProjectB.dll need to be in the GAC then we need to build the project and then copy the dlls into the GAC folder.
Thus when the WSP Builder runs it will pickup that the assemlbies need to go into the GAC and build the wsp solution correctly.
These post build events become more and more complex as the number of projects is included in the solution, more complexity equals more room for errors.
A Solution
In order to make things less complex I use the post build events for the projects to copy all the appropriate content from the project directory and build a directory structure under the solution dir.
This can be done as follows:-
echo Running WSP Builderecho Copying GAC Dlls to $(ProjectDir)GACcopy /y "$(TargetDir)*.dll" "$(ProjectDir)GAC\"

echo Copying 12 Directory to Solution Buildxcopy /S /E /I /H /Y "$(ProjectDir)12" "$(SolutionDir)Build\12\"

echo Copying GAC Directory to Solution Buildxcopy /S /E /I /H /Y "$(ProjectDir)GAC" "$(SolutionDir)Build\GAC\"

echo Running WSP Builder against FCT System Solutioncd "$(SolutionDir)Build\%programfiles%\WSPTools\WSPBuilderExtensions\wspbuilder" -WSPName [solutionfilename.wsp]-SolutionId [SolutionIDGUID]

echo Copying packages to Deployment\Packagecopy /y "$(SolutionDir)Build\*.wsp" "$(SolutionDir)Deployment\Package\" copy /y "$(ProjectDir)Package\*.*" "$(SolutionDir)Deployment\Package\":exit
Some enhancements
One of the annoying things when you are coding is that there is a cycle of fix, build, deploy, debug. If you are building the WSP file each time then the cycle between build->deploy->debug can be quite slow. To speed things up I use different build configurations. For example the Debug build does not call the wsp builder command but uses gacutil to add the assembly to the GAC or copies the assembly to the web application bin directory. The application pool is then recycled.
echo Copying content into $(SolutionDir)
copy /y /e /s/i “$(ProjectDir)\12” “$(SolutionDir)\Build\12”
For example:-
This is achieved in the following manner:-
I hope that you find this useful, I would love to hear about other ways that people achieve this and also if anyone has any enhancements to this solution.

Manage Content and Structure (An Unknown Error Occured)


>

Sometimes you have got to love SharePoint, or more importantly love the developers who developed SharePoint to return an exception message such as “An unknown error occured” when something bad happens.

This message occurred when using the Site Actions->Manage Content and Structure feature.

After some investigation a couple of posts on MSDN were found these talked about checking various xml files which customise the Publishing Editing Toolbar and Site Actions toolbar.

The MSDN post said to check that the files were both checked in and published.

However, this did not fix the problem. After further investigation I could see that some lists had two entries in the View All Site Content page (/_layouts/viewlsts.aspx), both which linked to the same list. So the problem is how can we get rid of one of these links?

The first idea was to backup the list as a list template and then delete the list, however this would change the list id when a new list was created from the template.

Instead I had the idea to use the recycle bin feature to bring the list back.

Deleting and restoring the list from the recycle bin did indeed fix the duplicate list links and also fixed the Manage Content and Structure feature!

Next, is to workout why these list entries are duplicated.