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
5. In SharePoint Customization Wizard, provide the local SharePoint web application URL and deploy as farm solution
6. Click Solutions Configuration drop down and select Configuration Manager
7. Make sure the Solution has 4 configurations Debug_SP2010, Release_SP2010, Debug_SP2013 and Release_SP2013. Copy settings from respective modes.
All added 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.
11. Right click the project and create a folders to store the assembly files of both the versions in respective folders.
12. Right click the project and click unload project
13. Right click the project again and click Edit project file
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
15. Add Reference to the appropriate assemblies to load from respective folders during compilation.
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.