Here is the behavior I'm trying to achieve in AppVeyor
- Build the code (stamp AssemblyInfo with
1.2.3.{build}
) - Test the code
- Create the nuget package if the tests passed
- Publish the beta package if the package created successfully (
1.2.3-beta-{build}
) - Also make the package available in artifacts.
Ideally when publishing a nuget package it would be published as prerelease. 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 good job of building and testing software out of github, but I don't seem to be able to control the nuget package version.
Given:
A package with the next semantic version of 1.2.3
I would expect the AppVeyor {version} variable to equate to 1.2.3.{build}
I would expect the nuget package version to equate to 1.2.3-beta-{build}
The first thing I tried was using variables in the {version}
box. Apparently this is not allowed. AppVeyor seems to only do variable substitution for {branch}
and {build}
as part of the {version}
. This means I'll have to maintain a separate variable for the semantic version.
The next challenge I ran into is that there's no way to set the nuget package version through the UI. It wants to default to be the same as the AppVeyor build version.
I decided to try creating the package using Powershell after the tests run. This works, but the Nuget Publish step wants to run before the package is created and there doesn't seem to be a way to control the execution order.
I think I'm on the wrong track. I need a conceptual reset.
Here is my appveyor.yml in its current (incorrect) state:
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 }
How do I fix this? Can I get the behavior I want?
You can use PowerShell and AppVeyor API to control version number. I would try composing appveyor.yml
as following:
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
来源:https://stackoverflow.com/questions/34273570/how-to-publish-beta-nuget-packages-out-of-appveyor