Supporting multiple Sitecore versions in a single Visual Studio solution

Large brands that own multiple Sitecore installations often need to deal with different versions inside the organization. While the desire to maintain some sort of common code base is desirable there are breaking changes between Sitecore versions that require some special care. We have a similar challenge for Keystone, we must support a wide range of versions of Sitecore (currently 7.2 to 8+).

Step 1: Build Configurations

The first step is to setup build configurations for each version of Sitecore. We decided on the naming convention SC{xx}rev{yyyyyy}. For example SC81rev151003. In the build configuration we define several custom variables: SitecoreVersion and SitecoreRevision and a custom constant for the version: Sitecore8.

Step 2: References

We manage references as imports. This gives us a single place to manage Sitecore references across all projects. This is done using an import directive that leverages the SitecoreVersion and SitecoreRevision variables.

Step 3: Sitecore Version Specific Code

In C# code, we leverage our custom constants to make alternative calls to the Sitecore API. As a general practice we make an effort to isolate any such conditional code to a single assembly.

We hope you find this helpful. Want to see more, contact us.