Xamarin Public Jenkins (auto-signing) 6bdd276d05 Imported Upstream version 5.0.0.42
Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
2017-04-10 11:41:01 +00:00

2.9 KiB

How to patch dotnet CLI with latest CoreFX

This document provides the steps necessary to consume a nightly build of CoreFX and CoreCLR.

Please note that these steps aren't necessary for official builds -- these steps are specific to consuming nightlies and thus unsupported builds. Also note that these steps are likely to change as we're simplifying this experience. Make sure to consult this document often.

Install prerequisites

  1. Install CLI 2.0.0-alpha SDK

Setup the project

  1. Create a new project

    • Creat a new folder for your app
    • Create project file by running dotnet new
  2. Add the CoreFX MyGet feed to your NuGet configuration.

    • You can do this globally but we recommend not doing this as this might affect other projects on your machine and you probably don't want that.
    • Instead, add a nuget.config that is local to your project. You can just put it next to the .csproj file. See the NuGet docs for details.
    <configuration>
      <packageSources>
        <add key="CoreFX" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
      </packageSources>
    </configuration>
    
  3. Select the nightly build from our feed

In order to consume the latest build, you'll need to update your .csproj as follows:

  1. Update TargetFramework, add RuntimeIdentifier as below (ideally dotnet.exe would infer your current architecture but it currently doesn't)
  2. Update package reference to match version selected above, as below
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <RuntimeIdentifier>win10-x64</RuntimeIdentifier>
  </PropertyGroup>

  <!-- Make sure to use Update, not Include! -->
  <ItemGroup>
    <PackageReference Update="Microsoft.NETCore.App" Version="2.0.0-beta-001386-00" />
  </ItemGroup>

</Project>

Restore packages so that you're ready to play:

$ dotnet restore

Consume the new build

Edit your Program.cs to consume the new APIs, for example:

using System;
using System.Net;

class Program
{
    static void Main(string[] args)
    {
        WebUtility.HtmlDecode("&amp;", Console.Out);
        Console.WriteLine();
        Console.WriteLine("Hello World!");
    }
}

Run the bits:

$ dotnet run

Rinse and repeat!