Last active
July 24, 2017 04:10
-
-
Save somewhatabstract/b2f2fe384b77a9c1e069f908bb3c4568 to your computer and use it in GitHub Desktop.
Getting appveyor to do prerelease and release nuget packages based on branch versus tag builds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 1.{build}.0 | |
os: Visual Studio 2015 | |
configuration: Release | |
platform: Any CPU | |
init: | |
- ps: $env:customnugetversion = if ($env:APPVEYOR_REPO_TAG -eq $True) { "$env:APPVEYOR_BUILD_VERSION" } else { "$env:APPVEYOR_BUILD_VERSION-$env:APPVEYOR_REPO_BRANCH" } | |
- ps: Update-AppveyorBuild -Version $env:customnugetversion | |
assembly_info: | |
patch: true | |
file: '**\AssemblyInfo.*' | |
assembly_version: '{version}' | |
assembly_file_version: '{version}' | |
assembly_informational_version: '{version}' | |
before_build: | |
- ps: nuget restore | |
build: | |
publish_nuget: true | |
publish_nuget_symbols: true | |
verbosity: minimal | |
deploy: | |
- provider: NuGet | |
server: https://www.myget.org/blahblahblah | |
api_key: | |
secure: blahblah | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Reflection; | |
using System.Runtime.CompilerServices; | |
using System.Runtime.InteropServices; | |
// General Information about an assembly is controlled through the following | |
// set of attributes. Change these attribute values to modify the information | |
// associated with an assembly. | |
[assembly: AssemblyTitle( "MyAssembly" )] | |
[assembly: AssemblyDescription( "" )] | |
[assembly: AssemblyConfiguration( "" )] | |
[assembly: AssemblyCompany( "" )] | |
[assembly: AssemblyProduct( "Awesomeness2016" )] | |
[assembly: AssemblyCopyright( "Copyright © 2016" )] | |
[assembly: AssemblyTrademark( "" )] | |
[assembly: AssemblyCulture( "" )] | |
[assembly: AssemblyVersion( "1.0.0.0" )] | |
[assembly: AssemblyFileVersion( "1.0.0.0" )] | |
// This attribute is important as it is what is referenced for the $version$ part of the nuspec | |
[assembly: AssemblyInformationalVersion( "1.0.0.0" ) ] |
Push changes to a branch and it builds a nuget package with a prerelease -branchname
at the end.
Push a tag and it builds a nuget package without that prerelease bit.
Ah so you always deploy to MyGet? I have a MyGet/NuGet setup for pre-release/release. But I'm pretty sure AppVeyor alllows different targets. Hmmmmm...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The key is to have the
AssemblyInformationalVersion
attribute in theAssemblyInfo.cs
as that is what gets used for the$version$
field substitution in the nuspec.https://gist.github.com/somewhatabstract/b2f2fe384b77a9c1e069f908bb3c4568#file-assemblyinfo-cs-L20
The other part is the scripts that init appveyor with a different version based off whether it's a tag build or not. The numeric versions ignore the additional string, but the informational attribute does not.
https://gist.github.com/somewhatabstract/b2f2fe384b77a9c1e069f908bb3c4568#file-appveyor-yaml-L6-L7