Linking the version in GH_AssemblyInfo and Properties/AssemblyInfo

After viewing many posts in the forum, I’m still confused about the versioning of building GH plugins.

To make things short, there’re two places where you can set the version of the plugin:
1. Properties/AssemblyInfo.cs
[assembly: AssemblyVersion("0.2.*")]

2. derived GH_AssemblyInfo

    public class igmInfo : GH_AssemblyInfo{
        public override string Version => "0.2.0";
}

After experimenting, things I’ve found out:

  1. option 2 controls the version info when using yak to publish plugins.
  2. option 1 controls the version in the generated .dll file that together with the .gha file,
  3. option 1 is also used when the plugin is not installed and you try to open a GH file with components from the plugin, and Grasshopper shows a warning dialog listing the components missing.

So my question is, is there a way to combine the two and only change the version once every time I make upgrades?

@xliotx after some playing around, it seems like this works for me:

[assembly: AssemblyVersion("0.0.*")]
namespace MyNameSpace
{

    public class PluginXInfo : GH_AssemblyInfo
    {
        //generic stuff
        public override string Name => "PluginX";
        public override Bitmap Icon => null;
        public override string Description => "Lorem Ipsum";
        public override Guid Id => new Guid("use your guid here");
        public override string AuthorName => "MBreau for BBB";
        public override string AuthorContact => "email@email.com";

        // reads from the attribute above, which handles auto-incrementing
        public override string Version => Assembly.GetExecutingAssembly().GetName().Version.ToString();
    }

Hi Matthew,

I’m trying to follow your method to update the version of my plugin, but I get the error in Visual Studio as below.
image

Do you have any suggestions?

After a few trials, the following method seems to work for me.

  1. Update Assembly version and Assembly file version from Properties in Visual Studio
    image
  2. Add the code below to make the Version consistent with the Assembly Version in GH_AssemblyInfo.
using System.Reflection;

namespace PluginX
{
    public class PluginX : GH_AssemblyInfo
    {
          ......

        // Keep Version automatically consistent with AssemblyVersion
        public override string Version
        {
            get
            {
                return AssemblyVersion;
            }
        }

        public override string AssemblyVersion
        {
            get
            {
                var assembly = Assembly.GetExecutingAssembly();
                var assemblyName = new AssemblyName(assembly.FullName);
                return assemblyName.Version.ToString();
            }
        }
    }
}

I copied the code to make the Version consistent from ShapeDiver. Guidelines for plugin developers