Nuget packages/supporting multiple Rhino version

What I did in the past was to use conditional expressions in the C# project files:

<PropertyGroup>
  <RhinoVersion>8</RhinoVersion> <!-- change here for Rhino 7 or 8 -->
</PropertyGroup>

<ItemGroup Condition=" '$(RhinoVersion)'=='8' ">
  <PackageReference Include="RhinoCommon" 
                    Version="8.5.24072.13001"
                    IncludeAssets="compile;build"/>
</ItemGroup>

<ItemGroup Condition=" '$(RhinoVersion)'=='7' ">
  <PackageReference Include="RhinoCommon" 
                    Version="7.35.23346.11001" 
                    IncludeAssets="compile;build"/>
</ItemGroup>

Then, you change the RhinoVersion in one place in your project file, and all package references are resolved to the correct version. I did find, however, that it is best to unload the solution first, then make the version change, followed by reloading the solution and performing a full rebuild.

5 Likes