dotnet_csproj only on tags

Will's Avatar

Will

28 Oct, 2018 11:56 AM

Hi, I'm trying to make it so when I push a tag like 0.0.2, appveyor will patch my dotnet core assemblies with this version number. I don't want to patch the assemblies on general pushes to master since they won't have a valid version number.

My general approach is to use the for: statement like so:

for:
-
  # only for git-tagged releases...
  matrix:
    only:
      - APPVEYOR_REPO_TAG: true
  dotnet_csproj:
    patch: true
    file: '**\*.csproj'
    assembly_version: '{appveyor_repo_tag_name}'
    informational_version: '{appveyor_repo_tag_name}'
    file_version: '{version} ({branch})'

I've also tried the following branches filter:

for:
-
  # only for git-tagged releases...
  branches:
    only:
      - /\d\.\d\.\d/
  dotnet_csproj:
    patch: true
    file: '**\*.csproj'
    assembly_version: '{appveyor_repo_tag_name}'
    informational_version: '{appveyor_repo_tag_name}'
    file_version: '{version} ({branch})'

However, dotnet_csproj does not appear to trigger. I have a deploy: statement right after the dotnet_csproj and neither seem to be applying (I know I can use on: inside a top-level deploy to fix this, though).

I'm tagging the releases like:

git tag 0.0.2
git push origin 0.0.2

So annotated tags aren't coming into play here. My full appveyor.yml is on GitHub. How can I make it so dotnet_csproj only runs for tags? Thanks!

  1. 1 Posted by Ilya Finkelshte... on 29 Oct, 2018 11:46 PM

    Ilya Finkelshteyn's Avatar

    This was an interesting problem :) Please check the simplified version of your YAML which should do it. There are comments inside to make it self-explainable, but feel free to ask any additional questions:

    # TAG_SCENARIO is a fake variable to leverage https://www.appveyor.com/docs/build-configuration/#skip-matrix-jobs-conditionally
    environment:
      matrix:
        - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
          RELEASE_ID: win-x64
          BUILD_ARTIFACT: nessie.exe
          TAG_SCENARIO: false # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
          
        - APPVEYOR_BUILD_WORKER_IMAGE: ubuntu1804
          RELEASE_ID: linux-x64
          BUILD_ARTIFACT: Nessie
          TAG_SCENARIO: false # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<     
                
        - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
          RELEASE_ID: win-x64
          BUILD_ARTIFACT: nessie.exe
          TAG_SCENARIO: true # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
          
        - APPVEYOR_BUILD_WORKER_IMAGE: ubuntu1804
          RELEASE_ID: linux-x64
          BUILD_ARTIFACT: Nessie      
          TAG_SCENARIO: true # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    
    build_script:
      - echo common build script
      
    for:
    -
      # only for NON-git-tagged releases...
      matrix:
        only:
          - TAG_SCENARIO: false # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
          
      skip_tags: true # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
      
    -
      # only for git-tagged releases...
      matrix:
        only:
          - TAG_SCENARIO: true # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    
      skip_non_tags: true # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    
      #version is ignored in for.matrix construct, because it is a general build level setting
      #https://www.appveyor.com/docs/build-configuration/#specializing-matrix-job-configuration 
      #version: '{appveyor_repo_tag_name}.{build}'
      
      #place variables other than "shotcut" ({build}, {branch}, {version}) in msbuild-style, e.g. $(appveyor_repo_tag_name)
      
      #note that tag like AssemblyVersion should exist in .csproj to be patched.
      
      dotnet_csproj:
        patch: true
        file: '**\*.csproj'
        assembly_version: '$(appveyor_repo_tag_name)' # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        informational_version: '$(appveyor_repo_tag_name)' # <<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
        file_version: '$(appveyor_repo_tag_name).{build} ({branch})' # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<  
      
      deploy_script:
        - echo tag deploy
    
  2. 2 Posted by Will on 30 Oct, 2018 05:13 AM

    Will's Avatar

    Oh, that's great! Thank you Ilya. The comments make it very clear.

    Thank you also for the tips about version and the msbuild syntax.

  3. 3 Posted by Ilya Finkelshte... on 30 Oct, 2018 06:00 PM

    Ilya Finkelshteyn's Avatar

    Sure, feel free to ping any time :)

  4. Ilya Finkelshteyn closed this discussion on 30 Oct, 2018 06:00 PM.

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

 

01 Oct, 2024 04:27 PM
26 Sep, 2024 03:49 PM
26 Sep, 2024 09:02 AM
25 Sep, 2024 07:07 PM
24 Sep, 2024 08:39 PM
24 Sep, 2024 06:47 AM