Reputation: 21
I'm currently working on a Blazor WASM app and I'd like to set a custom version (formatted like YEAR.MONTH.DAY.REVISION
) to all my built assemblies.
My goal is to use a makefile that does some stuff and compile the solution while setting the assemblies version.
I've already tried an extension for Visual Studio 2022 called Auto Versioning V3 that let you customize the version format and set it during the build.
The only problem is that if I launch dotnet build solution.csproj
in the command prompt the extension does not set the version to the files (VS extensions work only inside the IDE (?)).
Every solution is really welcome, thanks!
Upvotes: 2
Views: 923
Reputation: 1898
You can use environment variables for that. In your csproj files, add these property groups:
<PropertyGroup Condition="'$(APPVERSION)' == ''">
<InformationalVersion>1.0.0.0</InformationalVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(APPVERSION)' != ''">
<InformationalVersion>$(APPVERSION)</InformationalVersion>
</PropertyGroup>
If there is a environment variable "APPVERSION" set during the build, this will be used as InformationalVersion of the ouptut assembly, otherwise it will default to 1.0.0.0. You will just have to set APPVERSION in your makefile.
Upvotes: 1