Build a .NET Core 2.0 Application in AppVeyor

AppVeyor is one of the Continuous Integration Services in the cloud, ready to use, with minimal configuration. It provides a Windows Server image with tooling to build, test and deploy ours .NET applications. Among the baseline software is .NET Core, however, the version is 1.0.4 (at the time of writing this post).

If we are playing around with .NET Core 2.0, AppVeyor doesn’t offer the SDK (or the SDK build version that we need). Don’t panic, it is possible to download and install other .NET Core SDKs into the instance during our build process. After poking the Internet, the .NET Team offers a Powershell and a Bash script to download and install the SDK by version.

Following the documentation, we can install any SDK version using the terminal/command line. The version that my project needs is 2.0.0-preview2-006497. Let the games begin!

In a Powershell command line, I craft the command for my version, as:

.\dotnet-install.ps1 -Version 2.0.0-preview2-006497

And Powershell informed me:

Powershell dotnet_install.ps1 -Version 2.0.0-preview2-006497 command result

Hmmm, the required version doesn’t exist in the blob. A roadblock… Nothing major. Opening the script_source_code of the script, we can see that the SDK download link is built based on a few parameters.

The .NET Team already did all the work regarding downloading, unpacking and installing the SDK, and I can leverage the script to get the SDK from another source. The official download link is https://download.microsoft.com/download/F/A/A/FAAE9280-F410-458E-8819-279C5A68EDCF/dotnet-sdk-2.0.0-preview2-006497-win-x64.zip.

Doing a little tweak to the file, it is possible to point the download of the SDK to the official download link:

# $DownloadLinks = Get-Download-Links -AzureFeed $AzureFeed -AzureChannel $AzureChannel -SpecificVersion $SpecificVersion -CLIArchitecture $CLIArchitecture
$DownloadLinks = @("https://download.microsoft.com/download/F/A/A/FAAE9280-F410-458E-8819-279C5A68EDCF/dotnet-sdk-2.0.0-preview2-006497-win-x64.zip")

At this point, I have all the individual components to make the final solution. The appveyor.yml file needs to execute the dotnet_install script before building the .NET Core 2 application:

version: 0.0.{build}
image: Visual Studio 2017 Preview
build_script:
- ps: >-
    ./build/install-dotnet.ps1
    dotnet --version
    # Build application
test: off

And AppVeyor reports:

AppVeyor installs the .NET Core 2.0 SDK

Hurray, I have .NET Core 2.0 SDK installed, and my application is built successfully! 🙂

You can use this solution to install any version of the SDK that is not supported by the AppVeyor official image. You can jump to .NET Core 2.1!

Advertisements

One thought on “Build a .NET Core 2.0 Application in AppVeyor

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s