Hi Philippe,
I believe it's possible, but I find the simplest way is to create assemblies for each version.
I use the same code, just with build constants.
#if _2015
'do this
#elseif _2016
'do that
#else
'newer versions
#end if
You'll need to add pathing for each build version so that it points to the relevant version of the RevitAPI dlls.
e.g. in YourProjectName.vbproj.user file should look something like this:
<?xml version="1.0" encoding="utf-8"?><Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-2015|AnyCPU'"><ReferencePath>C:\Program Files\Autodesk\Revit 2015\</ReferencePath></PropertyGroup><PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-2016|AnyCPU'"><ReferencePath>C:\Program Files\Autodesk\Revit 2016\</ReferencePath></PropertyGroup></Project>
In your configuration settings for Release-2015 you should put custom constants like this: _2015=true,_2016=false
In your configuration settings for Release-2016 you should put custom constants like this: _2015=false,_2016=true
And of course, different build locations.
-Matt