How to publish nuget beta packages from AppVeyor

Here is the behavior I'm trying to achieve in AppVeyor

  • Create code (tick AssemblyInfo with 1.2.3.{build})
  • Check code
  • Create a nuget package if the tests passed
  • Post beta if package successfully created ( 1.2.3-beta-{build})
  • Also make the package available in artifacts.

Ideally, when you publish the nuget package, it will be published as a preview. In NuGet, this is done by adding alpha characters to the end of the package version. It is also considered bad practice to overwrite an existing package (indeed, many nuget implementations do not allow this).

AppVeyor does a great job of developing and testing software from github, but it looks like I can't control the version of the nuget package.

Given: Package with the next semantic version 1.2.3 I would expect the AppVeyor {version} variable to be equal 1.2.3.{build} I expected the nuget package version to be equal1.2.3-beta-{build}

The first thing I tried was to use the variables in the field {version}. Apparently this is forbidden. AppVeyor seems to only perform variable substitution for {branch}and {build}as part of {version}. This means that I will need to save a separate variable for the semantic version.

The next task I came across is that there is no way to install the nuget package version through the user interface. It wants by default to be the same as the AppVeyor build version.

, Powershell . , Nuget Publish , , , .

, . reset.

appveyor.yml () :

version: 0.1.0.{build}
configuration: Release
assembly_info:
  patch: true
  file: '**\AssemblyInfo.*'
  assembly_version: '{version}'
  assembly_file_version: '{version}'
  assembly_informational_version: '{version}'
environment:
  packageVersion: 0.1.0
nuget:
  account_feed: true
  project_feed: true
  disable_publish_on_pr: true
before_build:
- ps: nuget restore
build:
  verbosity: minimal
artifacts:
- path: '*.nupkg'
  name: nuget package
deploy:
- provider: NuGet
  api_key:
    secure: blahblahblah
  artifact: '*.nupkg'
  on:
    branch: master
on_success:
- ps: >-
    $releaseVersion= $env:packageVersion

    $buildNumber = $env:APPVEYOR_BUILD_NUMBER

    $betaVersion= "$releaseVersion-beta-$buildNumber"

    nuget pack Odin.nuspec -version $betaVersion

    Get-ChildItem .\*.nupkg | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }

? , ?

+4
1

PowerShell API AppVeyor . appveyor.yml :

version: 0.1.0.{build}

environment:
  packageVersion: 0.1.0

init:
- ps: $env:buildVersion = "$env:packageVersion.$env:appveyor_build_number"
- ps: $env:nugetVersion = "$env:packageVersion-beta-$env:appveyor_build_number"
- ps: Update-AppveyorBuild -Version $env:buildVersion

assembly_info:
  patch: true
  file: '**\AssemblyInfo.*'
  assembly_version: '$(buildVersion)'
  assembly_file_version: '$(buildVersion)'
  assembly_informational_version: '$(nugetVersion)'

configuration: Release

nuget:
  account_feed: true
  project_feed: true
  disable_publish_on_pr: true

before_build:
- nuget restore

build:
  verbosity: minimal

after_build:
- nuget pack Odin.nuspec

artifacts:
- path: '*.nupkg'

deploy:
- provider: NuGet
  api_key:
    secure: blahblahblah
  artifact: '*.nupkg'
  on:
    branch: master
+6

Source: https://habr.com/ru/post/1619956/


All Articles