Assembly Name Auto Update for Source Generators
NEW ARM64 support (please give feedback, i cannot easily test this.)
Summary
This extension automatically modifies the AssemblyName of a given assembly (.csproj) and reloads a set of dependent projects in a soltution.
Note: This is still a work in progress, so the following steps might change, going forward.
Support
I created a github repo here where issues can be created:
support repo
Also, there's a demo repo that shows how the extension works here:
demo repo
Usage:
- Add a file named
AutoUpdateAssemblyName.txt into the root folder of the solution (Solution Items in the Solution Explorer).
This file contains the project names of the projects you want to unload + reload when the project is built, one per line.
It now also allows for either paths to the .csproj file (which will be resolved from the solution directory, apparently) and nested solution-specific relative paths (if you don't have a .csproj extension.
- In the
.csproj of the Source generator project (which should be line1, see above), add a comment <!--AutoUpdateAssemblyName--> somewhere.
THEN DO ONE OF THESE THREE THINGS:
- Also in the
.csproj , in the <AssemblyName> property, make sure to add a . followed by a number at the end of the Assembly Name, so the extension knows what to increment. I'm not doing anything, if i can't find that.
- if this is not successful, i will try this: Also in the
.csproj , in the <AssemblyVersion> property, make sure to add a . followed by a number at the end of the Assembly Name, so the extension knows what to increment. I'm not doing anything, if i can't find that.
- if this is not successful, i will try this: in a Directory.Build.props file in the same folder as the solution, if there's a property defined that is called
AutoIncrementedAssemblyRevision , and that contains an integer value, I will increment it - YOU need to make sure you use that property in your AssemblyVersion or AssemblyName.
Note: currently, the .csproj parsing is very crude - i just pick the first part between <AssemblyName> and </AssemblyName> split that on . , and try to increment the last split part there. See TODOs further down.
TODO
- Only look at
AutoUpdateAssemblyName.txt when it's changed, not on each build (it's a small file, so that shouldn't matter, but ... well ...
- get the info from
AutoUpdateAssemblyName.txt int the generator's .csproj file, optionally.
Changelog
- 1.7.2 - Fixed (hopefully) a NRE
- 1.7 - Added functionality to update the AssemblyVersion instead of the AssemblyName or use the property AutoIncrementedAssemblyRevision defined in a Directory.Build.props file in the .sln folder.
- 1.6 - (hopefully) fixed VS crash because of an Error with DTE.ActiveDocument - using VS.Documents.GetActiveDocumentViewAsync now...
- 1.5 - Added arm64 compatibility (please give feedback)
- 1.4.2 - enabled finding nested projects for restarting, improved (hopefully, please give feedback) reloading
| |