Date based versioning

jonas.rapp's Avatar

jonas.rapp

07 Apr, 2015 01:22 PM

Hi
I have a versioning policy which is basically:
1.year.month.build For example: 1.2015.4.76
The autoincrementing build number is done with {build}, but is it possible to somehow use variables for the year and month as well?

/J

  1. Support Staff 1 Posted by Feodor Fitsner on 07 Apr, 2015 05:37 PM

    Feodor Fitsner's Avatar

    Hi Jonas,

    You can use Update build API in init section of your build. Something like:

    init:
      - ps: Update-AppveyorBuild -Version "1.$(Get-Date -format yyyy.M).$env:appveyor_build_number"
    
  2. 2 Posted by jonas.rapp on 07 Apr, 2015 05:44 PM

    jonas.rapp's Avatar

    Thanks!

    Now, as a clomplete newbie to both AppVeyor and yaml - is that something I can write in the Settings / Build Version Format field, or does it have to be done with some yaml magic?

  3. Support Staff 3 Posted by Feodor Fitsner on 07 Apr, 2015 05:46 PM

    Feodor Fitsner's Avatar

    You can't use date parts in version format.

    There is no yaml magic - it's PowerShell magic :) and you can put the same command to "Init script" field on UI (and choosing PS as script type):

    Update-AppveyorBuild -Version "1.$(Get-Date -format yyyy.M).$env:appveyor_build_number"
    
  4. 4 Posted by jonas.rapp on 07 Apr, 2015 05:52 PM

    jonas.rapp's Avatar

    Ah - I think I got it :)
    And then I leave the Build Version Format field blank, or is it overwritten anyway by the init script?

  5. Support Staff 5 Posted by Feodor Fitsner on 07 Apr, 2015 05:58 PM

    Feodor Fitsner's Avatar

    Yes, it will be overwritten, but do not leave it blank - put just {build} there.

  6. 6 Posted by jonas.rapp on 15 Apr, 2015 10:44 AM

    jonas.rapp's Avatar

    Hi again

    I have probably just missed something really stupid, but when I was going to adopt this to my next project, I get the following error during build:

    Build started
    SET /A "year=%Date:~10,4%"
    SET /A "month=%Date:~4,2%"
    Fetching repository commit (862f47a)...OK
    Total: 2.1 MB in 66 files
    Patching AssemblyInfo
    Patching VersionInfo.cs...Wrong version format for assembly patching: 1.2015.4.$2
    

    I just don't get it...

  7. 7 Posted by jonas.rapp on 15 Apr, 2015 10:59 AM

    jonas.rapp's Avatar

    Another thing noted:
    The build version shown in the build history is

    3.master
    2.master
    1.master
    
    In the previous project version is good, e.g. 1.2015.4.34 etc.
    But the settings are identical in the two projects.

    yaml from the new project:

    version: .{build}
    branches:
      only:
      - master
    configuration: Release
    init:
    - ps: Update-AppveyorBuild -Version "1.$(Get-Date -format yyyy.M).$env:appveyor_build_number"
    assembly_info:
      patch: true
      file: '**\VersionInfo.*'
      assembly_version: '{version}'
      assembly_file_version: '{version}'
      assembly_informational_version: '{version}'
    build:
      verbosity: minimal
    after_build:
    - 7z a Cinteros.XrmToolBox.Plugins_%APPVEYOR_BUILD_VERSION%.zip %APPVEYOR_BUILD_FOLDER%\Output\%CONFIGURATION%\Cinteros.Xrm.*.dll
    - appveyor PushArtifact Cinteros.XrmToolBox.Plugins_%APPVEYOR_BUILD_VERSION%.zip
    deploy:
    - provider: Environment
      name: GitHubCintXTB
    
  8. Support Staff 8 Posted by Feodor Fitsner on 15 Apr, 2015 06:08 PM

    Feodor Fitsner's Avatar

    Obviously, you can't put anything into AssemblyVersion and AssemblyFileVersion attributes. They only accept the value in the form a.b.c.d. Use just something like 1.{build} there.

  9. 9 Posted by jonas.rapp on 15 Apr, 2015 06:58 PM

    jonas.rapp's Avatar

    Obviously, no that is not a proper format.

    What I meant was that using the same settings, I don't understand why the two projects behave differently.
    When the first project generates a version like 1.2015.4.37 and the second, using the same settings, generates a version like 1.2015.4.$5.
    And why the first projects build is named 1.2015.4.37 when the second project is named 5.master.

    I was just looking for clues to why they behave differently using the same settings, if You might have any idea.

  10. Support Staff 10 Posted by Feodor Fitsner on 15 Apr, 2015 07:00 PM

    Feodor Fitsner's Avatar

    Ah, I see what you mean :) Assembly patching can automatically strip the suffix in versions of format a.b.c-suffix

  11. 11 Posted by jonas.rapp on 15 Apr, 2015 07:07 PM

    jonas.rapp's Avatar

    Great :)

    But is there a way to explain why this does not work?
    Because now I can't get it to work.

    Working yaml:

    version: '{build}'
    branches:
      only:
      - master
    configuration: Release
    init:
    - ps: Update-AppveyorBuild -Version "1.$(Get-Date -format yyyy.M).$env:appveyor_build_number"
    assembly_info:
      patch: true
      file: '**\AssemblyInfo.*'
      assembly_version: '{version}'
      assembly_file_version: '{version}'
      assembly_informational_version: '{version}'
    build:
      verbosity: minimal
    after_build:
    - 7z a FetchXMLBuilder_%APPVEYOR_BUILD_VERSION%.zip %APPVEYOR_BUILD_FOLDER%\FetchXMLBuilder\bin\%CONFIGURATION%\Cinteros.Xrm.*.dll
    - appveyor PushArtifact FetchXMLBuilder_%APPVEYOR_BUILD_VERSION%.zip
    deploy:
    - provider: Environment
      name: GitHubFXB
    
    Not working yaml:
    version: '{build}'
    branches:
      only:
      - master
    configuration: Release
    init:
    - ps: Update-AppveyorBuild -Version "1.$(Get-Date -format yyyy.M).$env:appveyor_build_number"
    assembly_info:
      patch: true
      file: '**\VersionInfo.*'
      assembly_version: '{version}'
      assembly_file_version: '{version}'
      assembly_informational_version: '{version}'
    build:
      verbosity: minimal
    after_build:
    - 7z a Cinteros.XrmToolBox.Plugins_%APPVEYOR_BUILD_VERSION%.zip %APPVEYOR_BUILD_FOLDER%\Output\%CONFIGURATION%\Cinteros.Xrm.*.dll
    - appveyor PushArtifact Cinteros.XrmToolBox.Plugins_%APPVEYOR_BUILD_VERSION%.zip
    deploy:
    - provider: Environment
      name: GitHubCintXTB
    
  12. Support Staff 12 Posted by Feodor Fitsner on 15 Apr, 2015 07:13 PM

    Feodor Fitsner's Avatar

    Don't see any difference in terms of setting version number.

    Try outputting it into build console with:

    init:
      - ps: "1.$(Get-Date -format yyyy.M).$env:appveyor_build_number"
    
  13. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 01:55 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac