Another look on tech

My thoughts on tech.

Build a .NET Core 2.0 Application in AppVeyor

10 August 2017

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 [source code]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

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 = @("")

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
- ps: >-
    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!