Compile .NET 5 Library

137 Views Asked by At

I am learning ASP.NET 5 (vNext). As part of that, I have a reusable library that I am porting over. The library is very basic and does not require any special dependencies. Currently, for this library, I've created my project.json file, which looks like this:

project.json

{
  "version": "1.0.0-*",

  "compilationOptions": {
    "warningsAsErrors": true
  },

  "dependencies": {
    "Microsoft.Framework.ConfigurationModel": "1.0.0-*",
    "Microsoft.Framework.ConfigurationModel.Json": "1.0.0-*"
  },

  "frameworks": {
    "dnx451": { },
    "dnxcore50": { }
  }
}

I then have just a basic file that looks like this:

Library.cs

using System;
namespace Test
{
  public class Library
  {
    public static void PrintLine(string line)
    {
      Console.WriteLine(line);
    }
  }
}

I am trying to figure out how to compile my code. I am trying to compile the code from the command line in Mac OS X. How do I compile my code?

1

There are 1 best solutions below

0
On BEST ANSWER

The command for compiling DNX projects is

dnu build

You run it in the directory where your project resides.

If you want to create a deployable, reusable NuGet package for other projects to consume, check out:

dnu pack