14 Apr 2021
Run correct app bundle
Before relying on the Interaction project provided by the Visual Studio solution template for Design Automation for Inventor, I used to update my app bundles and activities in other ways - like using Postman
Even with the Interaction project, you can run into problems: e.g. you forget to compile your project and so the zip file that gets uploaded as the new app bundle version is not up-to-date.
There could be other problems too: perhaps you did not set the correct alias for the latest version or the activity is not referencing the correct alias.
So, I started logging a version number to the console from the app bundle that I kept changing, and that way I could see if the latest version was running on the Design Automation server or not
Trace.TraceInformation("App Bundle v9");
But sometimes I forget to change it and upload a new app bundle, which in the case of one full of resource files can take a while.
Since the version number of the assembly (defined in AssemblyInfo.cs) already gets printed to the console (see below), perhaps I could just keep changing that.
The best thing would be to automate this - and you can. ?
If you use an asterisk in the version number (e.g. [assembly: AssemblyVersion("1.0.*")]), then that part will be changed after each build automatically. As discussed here, from the generated version number you can even figure out the build time.
Using this code I can now always see the build time of the app bundle that's running on the Design Automation server.
public void LogAssemblyVersion()
{
Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
DateTime buildDate = new DateTime(2000, 1, 1)
.AddDays(version.Build)
.AddSeconds(version.Revision * 2);
string displayableVersion = $"AppBundle {version} ({buildDate})";
Trace.TraceInformation(displayableVersion);
}
public void RunWithArguments(Document doc, NameValueMap map)
{
LogAssemblyVersion();
// etc