Export (0) Print
Expand All
Expand Minimize

Creating a Visual Studio Project for Windows SharePoint Services 3.0

Windows SharePoint Services 3

Visual How To

Applies to:  Microsoft Windows SharePoint Services 3.0, Microsoft Office SharePoint Server 2007, Microsoft Visual Studio 2005

Ted Pattison, Critical Path Training

May 2007

Overview

Development for Microsoft Windows SharePoint Services 3.0 often involves deploying custom source files into the WSS \TEMPLATE directory. It is helpful to create a Microsoft Visual Studio project with a directory structure that parallels the \TEMPLATE directory so you can automate copying your source files into the location required for deployment and testing.

Code It

Create a Visual Studio project by using the Class Library DLL project type. Next, create a \TEMPLATE directory inside the project. If you are creating one or more features, create a FEATURES directory inside the TEMPLATE directory and add your feature source files. If you are creating custom application pages, create a LAYOUTS directory. Within the LAYOUTS directory, create either a company-specific or project-specific directory and create your custom application pages inside it.

Figure 1. Your Visual Studio project with a directory structure parallel to the WSS\TEMPLATE directory

Create Visual Studio Project For SharePoint

 

Deployment

After you create the source files for components such as Features and application pages, create a batch file to automate copying these files into the \TEMPLATE directory. If you are testing a Feature, the batch file must also make calls to the STSADM.EXE command-line utility to install (and possibly activate) the Feature. If your solution contains an assembly that must be installed in the global assembly cache (GAC), your batch must also run a command with the utility named GACUTIL.EXE. Here is an example of a batch file that involves all these aspects of deployment for testing purposes.

@SET TEMPLATEDIR="c:\program files\common files\microsoft shared\
                  web server extensions\12\Template"
@SET STSADM="c:\program files\common files\microsoft shared\
             web server extensions\12\bin\stsadm"
@SET GACUTIL="c:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\
              Bin\gacutil.exe"

Echo Installing HelloWssDev.dll in GAC
%GACUTIL% -if bin\debug\HelloWssDev.dll

Echo Copying files to TEMPLATE directory
xcopy /e /y TEMPLATE\* %TEMPLATEDIR%

Echo Installing feature
%STSADM% -o installfeature -filename  HelloWssDev\feature.xml -force

REM - Uncomment next line when you need to restart IIS worker process
REM IISRESET

Notice that the three file paths at the beginning of this batch file contain line breaks to make them more readable in this document. However, be sure to remove these line breaks inside the actual install.bat file so that it works properly.

Post Build Events

The next step is to add a post-build event to your Visual Studio project so that it runs install.bat at the end of the build process. Notice that you also must change the current directory seen by install.bat to the current project directory. Here is what your post-build event should resemble.

cd $(ProjectDir)
install.bat
Read It

Developing components for custom solutions for SharePoint Products and Technologies can provide a powerful way to extend Windows SharePoint Services and Microsoft Office SharePoint Server 2007. When you create a Visual Studio project to create these components, you should have a structured approach for testing and debugging. In particular, your project will contain one of more of the following types of components.

  • Feature files

  • Site definition files

  • Application pages

  • Page templates

  • Web Part description files

  • Assembly DLLs installed in either the GAC or the bin directory

When you create a Visual Studio project that automates copying source files into the proper location and installing Features and assembly DLLs, you can test and debug much more quickly.

See It

Create Visual Studio Project

Watch the Video

Length: 11:20 | Size: 20.6 MB | Type: WMV

Explore It
Show:
© 2014 Microsoft