Sharepoint 2010 deployment using Visual Studio

In a Sharepoint, where deveopment is in Visual Studio and deployment to ITest is via Wsp I have a solution structure like this:

– Solution:MyCom.MyWepApp

– Project:Common.ProjectForSeveralWebAppsWsp //A Wsp packaging project including code common to several webapps

– Project:MyWepApp.Wa.Layout //Some MyWepApp specific code
– Project:MyWepApp.Wa.WepParts //Some more MyWepApp specific code
– Project:MyWepApp.Wa.WepAppWsp //A Wsp packaging project for above two project

– Project:MyWepApp.Ca.CentralAdminWsp //A Wsp packaging project including some features for the CentralAdmin

There are three Wsp projects:
– One for deploy to MyWepApp (MyWepApp.Wa.WepAppWsp) and
– one for deploy to CentralAdmin (MyWepApp.Ca.CentralAdminWsp) and
– one for deploy to several dependant webapps (Common.ProjectForSeveralWebAppsWsp)

The MyWepApp.Wa.WepAppWsp project don’t include any code, but its Package.package includes the features and the dll’s for the projects above it.

For the MyWepApp.Wa.WepAppWsp project change the content of the .csproj file. You must unload the project before doing that.

You will find:

<Project>
  <!-- removed for clarity -->
  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\SharePointTools\Microsoft.VisualStudio.SharePoint.targets" />
</Project>

Replace above with:

<Project>
  <!-- removed for clarity -->
  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\SharePointTools\Microsoft.VisualStudio.SharePoint.targets" />
  <PropertyGroup>
    <PostBuildEventDependsOn>$(PostBuildEventDependsOn);CreatePackage</PostBuildEventDependsOn>
  </PropertyGroup>
  <PropertyGroup>
    <!-- Copy package for WebApplication (created from the whole solution) -->
    <PostBuildEvent>copy $(TargetDir)$(SolutionName).wsp $(SolutionDir)_Deployment\$(SolutionName)\Wa-Wsp\</PostBuildEvent>
  </PropertyGroup>
  <ProjectExtensions>
    <VisualStudio>
      <FlavorProperties GUID="{BB1F664B-9266-4fd6-B973-E1E44974B511}">
        <DeploymentConfigurations>
          <DeploymentConfiguration Name="Attach only (MyCom)" Description="No deployment - only attach">
            <DeploymentSteps>CKS.Dev.SharePoint.Deployment.AttachToIISWorkerProcesses;CKS.Dev.SharePoint.Deployment.AttachToSPUCWorkerProcess</DeploymentSteps>
          </DeploymentConfiguration>
        </DeploymentConfigurations>
      </FlavorProperties>
    </VisualStudio>
  </ProjectExtensions>
</Project>

This will copy the wsp to a folder \_Deployment\ under the solution directory and put it in a subfolder created for WebApp deployment (\Wa-Wsp\) oppsed to a subfolder for CentralAdmin (\Ca-Wsp\) deployment.

For the Common.ProjectForSeveralWebAppsWsp project you could instead have like this:

  <PropertyGroup>
    <BuildDependsOn>$(BuildDependsOn);CreatePackage</BuildDependsOn>
  </PropertyGroup>
  <PropertyGroup>
    <!-- Copy package for this project -->
    <PostBuildEvent>copy $(TargetDir)$(TargetName)2010.wsp $(SolutionDir)_Deployment\$(TargetName)2010\$(TargetName)2010.wsp</PostBuildEvent>
  </PropertyGroup>

Notice the DeploymentConfiguration. This you can add if you have CKSDev installed. Its purpose is to add a DeploymentConfiguration for the project, where you can attach to IIS without doing a full deployment. That part is usefull for those projects containing code for GAC/Bin

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: