1

I'm working on a project where plugins are deployed in DLL's.

When deploying a DLL, it gets locked by the application. To update it I have to change the name of the DLL (since I can't overwrite the original), and update the app database to use the new version of the library.

I'd like to make this as automated as possible.

In AssemblyInfo, I've set the [assembly: AssemblyVersion("1.0.*")] to automatically increment.

I'm hoping that I can pull this version into the project properties Assembly Name, so that it automatically appends the version number to the generated DLL.

Is this possible at all with VS/C#?

Jamie
  • 168
  • 10
  • An assembly cannot be unloaded from the AppDomain once it's been loaded. But you can earmark a separate AppDomain for your plugins and discard the entire AppDomain when you wish to replace an assembly. Once the AppDomain is removed, the assembly files will become writeable again. – Pranav Negandhi Mar 18 '20 at 14:12
  • 1
    No, chicken-and-egg problem. You need the output name before you compile but can only find the assigned version number after you compile. No problem if you increment it yourself. You could perhaps consider renaming it afterwards. – Hans Passant Mar 18 '20 at 14:14
  • @HansPassant I don't mind the idea of renaming after compile, but I'm not sure where I would find the version number generated by `[assembly: AssemblyVersion("1.0.*")]`. – Jamie Mar 18 '20 at 14:23
  • @PranavNegandhi I'm not sure I follow. I don't have control over the application itself, can I do all of that from just modifying my DLL? – Jamie Mar 18 '20 at 14:24
  • https://stackoverflow.com/questions/1755504/programmatically-get-the-version-number-of-a-dll – Hans Passant Mar 18 '20 at 14:26
  • @HansPassant I'll consider it but at that point it probably goes beyond the effort of just manually maintaining the version number. – Jamie Mar 18 '20 at 14:34

1 Answers1

0

Following Hans advice that the file renaming can't be done during the build, I've decided to rename the file after build.

In order to find the version number quickly for renaming, I've removed the AssemblyFileVersion line from the AssemblyInfo file. Which will set the file version to the version number. Automatically Update Assembly File Version

After building the DLL I can check the file properties, where the version number will be listed as File version under the details tab.

I'll copy the version number from here and append it to the DLL name.

Jamie
  • 168
  • 10