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:
option 2 controls the version info when using yak to publish plugins.
option 1 controls the version in the generated .dll file that together with the .gha file,
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();
}
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();
}
}
}
}