-
Jul 29th, 2024, 08:14 PM
#1
Thread Starter
New Member
Managing version numbers for application+class and deployment project using Git
I've developed an application, class, and deployment project (all part of the same solution) which I recently transitioned version control over to Git. I'm releasing a new major version (2.0) and am fairly confused about how to handle version numbers. I'm hoping to get best practices on the mechanics of handling these values (I'm familiar with Semantic Versioning), and have the following questions:
- What is the difference between the deployment project's version and the application project and class library's assembly/file version?
- Why does the deployment project's version only permit 3 digit versions (e.g. 1.2.3), whereas the application project and class libraries have 4 digits in the assembly info (assembly version and file version)?
- Is there a way to have Git tags automatically populate any of these versions?
My client is writing software that relies on the class/DLL, so I want to ensure that they are able to differentiate between my releases.
Thanks!
SKSSF
-
Jul 30th, 2024, 05:04 AM
#2
Re: Managing version numbers for application+class and deployment project using Git
I will go with the easiest one first... https://gitversion.net/docs/ is a nice tool for automatically versioning your .Net artifacts (exe, dll, etc) the easiest way to get this up and running is follow the instructions at https://gitversion.net/docs/usage/msbuild if you are just building with Visual Studio. There are other links on there for integrating with CI/CD and other forms of automation.
The other two points are a bit more tricky...
The Deployment project's version would normally be the version number for the actual application itself. This is the number that matters to the people installing your software, with bigger numbers being newer versions - pretty much what you are getting with semver.org (always a good choice IMHO).
It is quite common for the individual assembly versions to match this product version, especially if the entire application (application, class library, etc.) is all part of the same solution, and built as a single unit.
If you are building and packaging the class libraries separately then you might find that the individual libraries have their own versioning scheme (updates / bug fixes) that doesn't correspond to the overall application's version. You might however increase the application's version number if you are updating the dependencies to newer versions as well.
e.g. You might have the front end application and the deployment package versioned as 2.0.0 and the class library might be on 1.9.2 - the two wouldn't need to match.
Not sure why there is a difference in the number of digits allowed, although I never use more than 3 anyway as I tend to stick with semver as a numbering scheme.
-
Jul 30th, 2024, 01:52 PM
#3
Thread Starter
New Member
Re: Managing version numbers for application+class and deployment project using Git
Thanks for the comprehensive response! Do you have a VB-specific tutorial? The instructions you linked to are throwing me for a loop...in particular, the following:
- Regarding the PackageReference, I can't seem to understand where that text should be inserted. I see no <PackageReference Include="GitVersion.MsBuild" Version="5.12.0">tag in any of my .vbproj files.
- The WPF specific concerns is similarly confusing--there are no files in my solution that contain <PropertyGroup>
Also, despite GitVersion.MsBuild v6.0.0 being installed on the two projects in my solution (application and class library, the deployment project isn't shown as an option), I have the following lines in both .vbproj files:
Code:
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\GitVersion.MsBuild.6.0.0\build\GitVersion.MsBuild.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\GitVersion.MsBuild.6.0.0\build\GitVersion.MsBuild.props'))" />
<Error Condition="!Exists('..\packages\GitVersion.MsBuild.6.0.0\build\GitVersion.MsBuild.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\GitVersion.MsBuild.6.0.0\build\GitVersion.MsBuild.targets'))" />
</Target>
Finally, will GitVersion.MsBuild also update the deployment project's version?
Any recommendations would be very much appreciated!
-
Aug 2nd, 2024, 03:25 PM
#4
Re: Managing version numbers for application+class and deployment project using Git
Hi, not had chance to look at this using vb or getting the version from a tag, tended to use this with c# as part of a CI/CD pipeline.
I will see if I can get some time to try it out with vb...
What version of .Net are you using?
Last edited by PlausiblyDamp; Aug 3rd, 2024 at 07:56 AM.
-
Aug 2nd, 2024, 03:54 PM
#5
Thread Starter
New Member
Re: Managing version numbers for application+class and deployment project using Git
Oh wow that would be great! I'm running VS 2022. Thank you!!
-
Aug 3rd, 2024, 09:16 AM
#6
Re: Managing version numbers for application+class and deployment project using Git
For some reason I couldn't get that to work with VB running with a local repo, no idea why. However https://www.clarius.org/GitInfo/ is an alternate approach.
If you follow the instructions to add that nuget package, then tag your repo with a version number e.g. git tag v1.1.0 then on a build it will make the information available to your app. The docs give a couple of examples of how to use this information to embed the meta data into your assemblies (either through the vbproj file, or from a code file).
Not sure if it would work with the installer project however.
-
Aug 3rd, 2024, 12:11 PM
#7
Thread Starter
New Member
Re: Managing version numbers for application+class and deployment project using Git
This is fantastic--will check it out and report back. Thank you again!
-
Aug 6th, 2024, 02:32 AM
#8
New Member
Re: Managing version numbers for application+class and deployment project using Git
hey SKSSF. managing versions in Git is an important topic .the diffrence between the deployment project's version and the application a nd class library versions is that the deploynment version refers to the entire package , while application versions are specific to the code. For automatic taging you can use scripts to update version numbers in project files based on Git tags. this will make version managment easier and help your clients differentiate between releases.
cheers,
celeste
**Links removed by Site Administrator so it doesn't look like you're spamming us. Please don't post them again.**
-
Aug 7th, 2024, 08:56 PM
#9
Thread Starter
New Member
Re: Managing version numbers for application+class and deployment project using Git
Thanks, PlausiblyDamp & Celeste 84--I got this to work after some fiddling around. For fellow VB users, here's what I did:
- Installed GitInfo from the Package Manager prompt:
Code:
PM> Install-Package GitInfo
- Modified AssemblyInfo.vb by commenting out references to the existing AssemblyVersion and AssemblyFileVersion, then adding the following code:
Code:
<Assembly: AssemblyVersion(ThisAssembly.Git.BaseVersion.Major + "." + ThisAssembly.Git.BaseVersion.Minor + "." + ThisAssembly.Git.BaseVersion.Patch)>
<Assembly: AssemblyFileVersion(ThisAssembly.Git.SemVer.Major + "." + ThisAssembly.Git.SemVer.Minor + "." + ThisAssembly.Git.SemVer.Patch)>
<Assembly: AssemblyInformationalVersion(
ThisAssembly.Git.SemVer.Major + "." +
ThisAssembly.Git.SemVer.Minor + "." +
ThisAssembly.Git.Commits + "-" +
ThisAssembly.Git.Branch + "+" +
ThisAssembly.Git.Commit)>
- Modified the .vbproj file by adding the following after the last PropertyGroup close tag (not sure if location matters, this is what I did):
Code:
<PropertyGroup>
<GitInfoReportImportance Condition="'$(Configuration)' == 'Release'">high</GitInfoReportImportance>
</PropertyGroup>
<PropertyGroup>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
</PropertyGroup>
<PropertyGroup>
<GenerateAssemblyFileVersionAttribute >false</GenerateAssemblyFileVersionAttribute >
</PropertyGroup>
<PropertyGroup>
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
</PropertyGroup>
- Tagged the original commit in my Git repo as v1.0.0
- Added some code to display the version in my form's titlebar:
Code:
Me.Text = "My program name v" & ThisAssembly.Git.SemVer.Major & "." & ThisAssembly.Git.SemVer.Minor & "." & ThisAssembly.Git.SemVer.Patch & "-" & ThisAssembly.Git.Branch & "+" & ThisAssembly.Git.Commit
Still have to update the installer project version manually, but I can handle that. Thanks for your help!
SKSSF
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|