Skip to content

VersionPrefix defaults to 1.0.0 regardless of whether Version actually starts with 1.0.0 or not #93

Description

@nguerrera

Today we have in Microsoft.NETCore.Sdk.targets (with one no-op line removed for brevity):

    <VersionPrefix Condition=" '$(VersionPrefix)' == '' ">1.0.0</VersionPrefix>
    <Version Condition=" '$(Version)' == '' and '$(VersionSuffix)' != '' ">$(VersionPrefix)-$(VersionSuffix)</Version>
    <Version Condition=" '$(Version)' == '' ">$(VersionPrefix)</Version>

The strange thing about this this logic is that if I, for example, set <Version> to 1.2.3-beta in my project, then <VersionPrefix> will be set to 1.0.0, but not used for anything. I worry that this will lead to incorrect dependencies on <VersionPrefix> always being set and meaningful.

I see two possible solutions:

(1) Only default <VersionPrefix> if we're going to use it:

    <VersionPrefix Condition="'$(Version)' == '' and '$(VersionPrefix)' == ''>1.0.0</VersionPrefix>
    <Version Condition=" '$(Version)' == '' and '$(VersionSuffix)' != '' ">$(VersionPrefix)-$(VersionSuffix)</Version>
    <Version Condition=" '$(Version)' == '' ">$(VersionPrefix)</Version>

(2) Eliminate <VersionPrefix> as a concept and just append <VersionSuffix> (if any) to <Version>:

    <Version Condition=" '$(Version)' == '' ">1.0.0</Version>
    <Version Condition=" '$(VersionSuffix)' != ''>$(Version)-$(VersionSuffix)</Version>

I am leaning towards (2) because:

  • The logic is simpler to maintain and reason about.
  • I can introduce a build system that appends version information without touching projects and switching <Version> to <VersionPrefix>

Another issue: I wonder if the - separating parts should be hard-coded. If I want to use http://semver.org/spec/v2.0.0.html I might want to append with + or . instead. Should we just require the -, ., or + to be part of the suffix? I think so:

   <Version Condition=" '$(VersionSuffix)' != ''>$(Version)$(VersionSuffix)</Version>

Activity

  1. self-assigned this
    on Aug 25, 2016
  2. changed the title [-]VersionPrefix handling issues[/-] [+]VersionPrefix defaults to 1.0.0 regardless of whether Version actually starts with 1.0.0 or not[/+] on Aug 25, 2016
  3. eerhardt commented on Aug 25, 2016

    @eerhardt
    Member

    Another issue: I wonder if the - separating parts should be hard-coded.

    The reasoning here was so the current CLI behavior could be preserved. Today, the project.json says:

      "version": "1.0.0-beta-*",

    And then users building the project can say

    dotnet build --version-suffix 12345
    

    And the output assembly would get version 1.0.0-beta-12345.

    If we forced $(VersionSuffix) to contain the - prefix, users would have to start saying:

    dotnet build --version-suffix -12345
    
  4. nguerrera commented on Aug 25, 2016

    @nguerrera
    ContributorAuthor

    If <Version> were to have '*' that is replaced by suffix, then it would be a non issue. My issue is I may want to turn 1.0.0-beta into 1.0.0-beta.999 not 1.0.0-beta-999 following semver 2.

  5. nguerrera commented on Aug 25, 2016

    @nguerrera
    ContributorAuthor

    Looking at the prior art with -* in the json, I am now thinking we should just use msbuild evaluation for this sort of buildsystem supplied info.

    Instead of -*, I can put arbitrary properties in my version:

    <Version>1.0.0-beta-$(BuildNumber)</Version>
    

    I can put these properties where I want and with whatever separators I want, etc .etc. This seems better than -* to me.

    Then, instead of dotnet build --version-suffix 12345, I can do dotnet build -p:BuildNumber=12345. (Assuming dotnet build supports passing arbitrary msbuild args and that's the syntax, but we should support passing properties in some way.)

    Basically, I'm wondering if we even need --version-suffix or if we should just lean on msbuild flexibility for this sort of thing as part of the conversion.

  6. eerhardt commented on Aug 25, 2016

    @eerhardt
    Member

    @BlackDwarf - the PM to weigh in on needing --version-suffix.

  7. eerhardt commented on Aug 25, 2016

    @eerhardt
    Member

    My opinion is that I agree with @nguerrera. With the move to MSBuild, the user gets full flexibility to use whatever property they want to make up the $(Version), and the CLI doesn't need special knowledge anymore.

    However, it is good to lead users down a "path of success", which is what --version-suffix and $(VersionSuffix) are trying to do. So I'd like to keep a drop dead simple/guided way to version a user's projects. Today there is no guided way, which leads to people doing crazy things or copying something they don't understand.

    If we can come up with a better guided experience for the 80% case, let's do it.

  8. brthor commented on Sep 6, 2016

    @brthor
    Contributor

    @davkean, @livarcocc, and I sat down and thought what if versions migrated directly:

    <Version>1.0.0-preview-*</Version>

    Then <VersionSuffix> can be passed in to populate the * (a straight replace), or if no VersionSuffix is passed in the -* will be removed from the version. This is equivalent to the behavior in project.json today.

    IMO this is more intuitive than the 3 Property Prefix/Suffix/Version approach.

  9. eerhardt commented on Sep 6, 2016

    @eerhardt
    Member

    When does the <VersionSuffix> replace the *? It can't happen in the Sdk.props file, since the user's <Version> property won't be set yet. So it will have to happen in the Sdk.targets file. Will it be confusing that at one point the <Version> property's value will be 1.0.0-preview-*, but then later it will be changed to 1.0.0-preview-123? So depending on when a chunk of code reads the value, it will have different values. If that is OK, then this sounds like a good plan to me.

  10. brthor commented on Sep 7, 2016

    @brthor
    Contributor

    @eerhardt I think the version property would remain with the star but we would populate another generated property with the evaluated value.

  11. eerhardt commented on Sep 7, 2016

    @eerhardt
    Member

    @eerhardt I think the version property would remain with the star but we would populate another generated property with the evaluated value.

    Isn't this just a "3 Property" approach as well?

    1. Version
    2. VersionSuffix
    3. another generated property with the evaluated value

    So, if I'm not mistaken, the proposed change is to:

    1. Add the -* to VersionPrefix.
    2. Rename VersionPrefix to Version.
    3. Create a new property that is the evaluated Version with -* replaced with VersionSuffix.

    What if we still do the rest, but we don't rename VersionPrefix to Version? So we generate:

    <VersionPrefix>1.0.0-preview-*</VersionPrefix>

    And then we populate the <Version> property with the -* replaced?

  12. modified the milestones: 1.0 RC, on Sep 16, 2016
  13. 7 remaining items

  14. modified the milestones: 1.0 RC, on Nov 3, 2016
  15. modified the milestones: 1.0 RC2, 1.0 RC3 on Nov 29, 2016
  16. modified the milestones: 1.0 RC3, 1.0 RTM on Jan 13, 2017
  17. modified the milestones: 1.1, 1.0 RTM on Feb 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions