Wednesday, August 19, 2015

Create a common visual studio project to develop different versions of SharePoint solutions


The following sample is to illustrate how to create a common visual studio project to develop different versions of SharePoint solutions. In some case we may need to develop a solution that would to be deployed in different versions of SharePoint. In this article we discuss about developing a common solution using Visual studio that can run for both SharePoint 2010 and 2013.


1.      Launch Visual Studio 2012 from a machine where SharePoint 2010 is installed
2.      Click New project
3.      Select .NET Framework 3.5 and select SharePoint 2010 – Empty Project
4.      Provide the name, solution name and click Ok
Create SharePoint Empty Project
5.      In SharePoint Customization Wizard, provide the local SharePoint web application URL and deploy as farm solution
Deploy as farm solution
6.      Click Solutions Configuration drop down and select Configuration Manager
Configuration Manager
7.      Make sure the Solution has 4 configurations Debug_SP2010, Release_SP2010, Debug_SP2013 and Release_SP2013. Copy settings from respective modes.
Configuration settings
Debug 2010 Configuration Manager
Release 2010 Configuration Manager
Debug 2013 Configuration Manager
Release 2013 Configuration Manager
All added configurations
All Configurations
8.      Right click the Project and Select properties.
9.      Select Build section, select “Debug_SP2010” from Configuration.
10.   Enter the value as “SP2010” for “Conditional Compilation Symbols” field. Give the same value for “Release_SP2010” also. Similarly provide “SP2013” for “Debug_SP2013” and “Release_SP2013” configurations.
Build information
Build information
11.   Right click the project and create a folders to store the assembly files of both the versions in respective folders.
Create Folders for binaries
12.   Right click the project and click unload project
13.   Right click the project again and click Edit project file
Edit solutions files
14.   Add <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> under <PropertyGroup></PropertyGroup> for both Debug_2010 and Release_2010 configurations. Also add
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> for both Debug_2013 and Release_2013 configurations
Set Target Framework version
15.   Add Reference to the appropriate assemblies to load from respective folders during compilation.
Add references
16.   Add all required artifacts to the project and compile/build by setting the configuration manager to appropriate build version to get respective SharePoint solutions.
Configuration manager

No comments:

Post a Comment