I would like to automatically add the repository version from Subversion to my software version. For that I found out that SubWCRev.exe could be used with the help of a pre-build event command.
I created a template: "AssemblyInfo.template.txt"
using System.Reflection;
[assembly: AssemblyVersion("1.0.0.$WCREV$")]
[assembly: AssemblyFileVersion("1.0.0.$WCREV$")]
I Also added the pre-build event line:
"C:\Program Files\TortoiseSVN\bin\SubWCRev.exe" "$(ProjectDir)." "$(ProjectDir)AssemblyInfo.template.txt" "$(ProjectDir)AssemblyInfo.cs"
The issue I face is that when I build the application, the Assembly.cs file is generated with the values in my Project.csproj file.
Is using "SubWCRev" obsolete for what I want to do? or should I do something differently?
I'm also wondering how the "pre-build event" could be updated to ensure it could work for other users on other PCs too.
Edit: If I create a random static class that contains a string variable with the revision number, it works but the program version is not set with the correct value in this way. At least it means the pre-built event works fine. It seems with newer version of Visual studio the assembly file is created when building. Should I try to modify the values my Project.csproj file? It feels as if it would be the wrong approach.
"SubWCRev" still works. The process is largely the same as before. The one missing piece is to set the following in the project's ".csproj" file:
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<SpaRoot>ClientApp\</SpaRoot>
<SpaProxyServerUrl>blah blah blah</SpaProxyServerUrl>
<SpaProxyLaunchCommand>npm start</SpaProxyLaunchCommand>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
This prevents the default generation of assembly info from project information.