How to call the AssemblyVersion Patch, from the build script

bob.lokerse's Avatar

bob.lokerse

05 Oct, 2015 12:42 PM

I can get the gitVersion now, and build up the version I want to use:
    set gitVersion=%APPVEYOR_REPO_BRANCH:~-4%
    set version=%gitVersion%.%APPVEYOR_BUILD_NUMBER%

The AppVeyorBuild can be updated with this,
    appveyor UpdateBuild -Version %version%

But how to call the AssemblyVersion patch?
(I put the above commands in the build script)

  1. Support Staff 1 Posted by Feodor Fitsner on 05 Oct, 2015 04:25 PM

    Feodor Fitsner's Avatar

    You can put those commands to init section of appveyor.yml (thus they run before git clone) and then just enable assembly patching declaratively.

  2. 2 Posted by bob.lokerse on 05 Oct, 2015 06:35 PM

    bob.lokerse's Avatar

    Thanks!
    I got it working:

    init:
    - cmd: "set appVeyorBuildVersion=%appveyor_build_version%\necho appVeyorBuildVersion:%appVeyorBuildVersion% \n\nset branch=%APPVEYOR_REPO_BRANCH%\necho branch:%branch%\n\nset gitVersion=%branch:~-3%\necho gitversion:%gitVersion%\n\nset newVersion=%gitVersion%.%APPVEYOR_BUILD_NUMBER%\necho %newVersion%\n\n"
    - cmd: appveyor UpdateBuild -Version "%newVersion%"
    
    assembly_info:
      patch: true
      file: '**\AssemblyInfo.*'
      assembly_version: '{version}'
      assembly_file_version: '{version}'
      assembly_informational_version: '{version}'
    build_script:
    - cmd: "echo Building version:%appveyor_build_version%"
    - cmd: "nuget restore\nmsbuild MySolution.sln /t:build /p:Configuration=Release"
    

    General info, for others:
    Now I have a dummy version in my AssemblyVersion.cs. I set the version in Sourcetree (GitFlow) when I create a release branch. For example: v1.2.
    That version (1.2) with the appVeyor build number is used in Appveyor, the patched AssemblyVersion and in the nuget package for Octopus Deploy (which creates a Release based on the nuget package version).

  3. Support Staff 3 Posted by Feodor Fitsner on 05 Oct, 2015 11:31 PM

    Feodor Fitsner's Avatar

    Cool, thanks for sharing the solution!

  4. 4 Posted by george.polevoy on 21 Mar, 2016 06:32 PM

    george.polevoy's Avatar

    Is it possible do achieve the same in GUI mode, without using an ".yml" file in the repository?

    What is the GUI equivalent of the init" section of an ".yml"?

    I tried to pass the custom versioning script with the "clone script" parameter, but it turns out the clone script replaces cloning of the repository which is not what I want.

  5. Support Staff 5 Posted by Feodor Fitsner on 21 Mar, 2016 07:16 PM

    Feodor Fitsner's Avatar

    "Init" script can be set on Environment tab of project settings.

    -Feodor

  6. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:04 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