This is a follow up to https://github.com/dotnet/aspnetcore/pull/32023. Essentially, we need to port the logic https://github.com/dotnet/runtime/blob/c7e02f3773da25946328eba150a70caa3b0e4c74/eng/versioning.targets#L53-L85 to aspnetcore.