adamralph / minver

🏷 Minimalistic versioning using Git tags.
Apache License 2.0
838 stars 60 forks source link

MinVerBuildMetadata included in .Net 8 SDK build but not .Net 6 SDK #934

Closed Ripper555 closed 9 months ago

Ripper555 commented 9 months ago

Version(s)

I have only tested this on v4.3.

To reproduce

Steps to reproduce the behaviour:

I have MinVer installed as a nuget package in my WPF application. In my project I updated to .net 8 sdk. When I did a not tagged build it showed +{MinVer BuildMetadata} at the end of the product version. When I added global.json to target .Net 6 sdk it didn't.

Screenshot 2023-11-19 173504 Screenshot 2023-11-19 173113

Expected behaviour

I'm assuming the expected behavior is to not include the metadata of the commit. That's at least how I want it.

Actual behaviour

MinVerBuildMetadata included in .Net 8 SDK

Workarounds

I don't know how to workaround this.

bording commented 9 months ago

@Ripper555 It's not really clear to me what problem you're describing here. Please give some concrete examples of what you're seeing. What's the actual version output you're seeing in both scenarios? Where are you looking to see the versions?

Ripper555 commented 9 months ago

@bording Yes, my apologies. I updated my first comment to try to be clearer. To recap I use MinVer in my WPF app to update the product version for the app that is displayed to the user. Building the app with the .Net 8 SDK adds the Commit data to it. The older SDKs don't. I added screen shots above to hopefully make it clearer.

bording commented 9 months ago

@Ripper555 Yes, thanks that does clear things up. What you're seeing is that the .NET 8 SDK includes Source Link by default now. MinVer does not include the commit hash in the version. Source Link is responsible for that.

Source Link is generally a good thing to have, and it's only adding the commit hash to the informational version, so it shouldn't really interfere with any other versioning uses. It's quite common to include a commit hash in the version to let you know what commit the binary was built from.

There are ways to disable Source Link if you really don't want it, but I recommend reading up on what Source Link does for you and consider keeping it enabled. Being able to debug directly into source code can be really useful!

adamralph commented 9 months ago

@Ripper555 to reiterate, although the commit hash ("6a882.." in your example) is being added to the build metadata part of the version, it is not MinVer that is doing that (as @bording says) and it has nothing to do with MinVerBuildMetadata. The .NET 8 SDK is doing it.

This is a breaking change in the .NET 8 SDK:

As a side effect, commit information is included in the InformationalVersion value of built libraries and applications.

As @bording says, you can disable this behaviour, but it has benefits. If you still want to display InformationalVersion to your users, but you don't want to display the commit hash (or any other build metadata) then I suggest you strip it out, by splitting the version string on "+" and using only the first value.

Given that this is SDK behaviour, and not related to MinVer, I'm closing this issue. If you want to discuss it any further in the context of MinVer, please start a discussion.

Ripper555 commented 9 months ago

Yes, thank you for the help. I would not have been able to fix this without your help.