0

I'm so excited to code dotNet on my mac.

Im facing issues with the aspnet nancy yeoman generator

i can restore but when i try to build the project it says.

Project api (DNX,Version=v4.5.1) will be compiled because expected outputs are missing Compiling api for DNX,Version=v4.5.1 /Users/garrison/projects/dotNet/garrison/api/project.json(18,20): error DOTNET1012: The reference assemblies directory was not specified. You can set the location using the DOTNET_REFERENCE_ASSEMBLIES_PATH environment variable. /Users/garrison/projects/dotNet/garrison/api/project.json(3,28): warning DOTNET1015: The 'compilationOptions' option is deprecated. Use 'buildOptions' instead. /Users/garrison/projects/dotNet/garrison/api/project.json(10,61): error NU1001: The dependency mscorlib could not be resolved. /Users/garrison/projects/dotNet/garrison/api/project.json(11,51): error NU1001: The dependency mscorlib could not be resolved. /Users/garrison/projects/dotNet/garrison/api/project.json(10,61): error NU1001: The dependency mscorlib could not be resolved. /Users/garrison/projects/dotNet/garrison/api/project.json(11,51): error NU1001: The dependency mscorlib could not be resolved. /Users/garrison/projects/dotNet/garrison/api/project.json(10,61): error NU1001: The dependency System could not be resolved. /Users/garrison/projects/dotNet/garrison/api/project.json(11,51): error NU1001: The dependency System could not be resolved. /Users/garrison/projects/dotNet/garrison/api/project.json(10,61): error NU1001: The dependency System could not be resolved. /Users/garrison/projects/dotNet/garrison/api/project.json(11,51): error NU1001: The dependency System could not be resolved. /Users/garrison/projects/dotNet/garrison/api/project.json(10,61): error NU1001: The dependency System.Core could not be resolved. /Users/garrison/projects/dotNet/garrison/api/project.json(11,51): error NU1001: The dependency System.Core could not be resolved. /Users/garrison/projects/dotNet/garrison/api/project.json(10,61): error NU1001: The dependency System.Core could not be resolved. /Users/garrison/projects/dotNet/garrison/api/project.json(11,51): error NU1001: The dependency System.Core could not be resolved. /Users/garrison/projects/dotNet/garrison/api/project.json(10,61): error NU1001: The dependency Microsoft.CSharp could not be resolved. /Users/garrison/projects/dotNet/garrison/api/project.json(11,51): error NU1001: The dependency Microsoft.CSharp could not be resolved. /Users/garrison/projects/dotNet/garrison/api/project.json(10,61): error NU1001: The dependency Microsoft.CSharp could not be resolved. /Users/garrison/projects/dotNet/garrison/api/project.json(11,51): error NU1001: The dependency Microsoft.CSharp could not be resolved. /Users/garrison/projects/dotNet/garrison/api/project.json(10,61): error NU1001: The dependency System.Runtime could not be resolved. /Users/garrison/projects/dotNet/garrison/api/project.json(10,61): error NU1001: The dependency System.Collections.Concurrent could not be resolved.

Compilation failed. 1 Warning(s) 19 Error(s)

the weird is that this does not happen with empty or regular aspnet applications, so i wonder why its crying about the environment variable just for this template.

1 Answers1

2

There are several problems:

  1. The Nancy generator generates ASP.NET Core RC1 application, while you're using RC2.
  2. Nancy does not currently support .Net Core, it seems it will support it in version 2.0.

This means that if you really want to run Nancy on Unix, is seems you can use use ASP.NET Core RC2, but you have to run it on mono, instead of .Net Core.

To make it run, take the source generated by yo and modify it as follows (assuming your application is called NancyApplication):

project.json:

{
    "version": "1.0.0-*",
    "buildOptions": {
        "emitEntryPoint": true
    },
    "tooling": {
        "defaultNamespace": "NancyApplication"
    },
    "dependencies": {
        "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
        "Microsoft.AspNetCore.Owin": "1.0.0-rc2-final",
        "Nancy": "1.4.3"
    },
    "frameworks": {
        "net451": {
        }
    }
}

Startup.cs:

namespace NancyApplication
{
    using Microsoft.AspNetCore.Builder;
    using Microsoft.AspNetCore.Hosting;
    using Nancy.Owin;

    public class Startup
    {
        public void Configure(IApplicationBuilder app)
        {
            app.UseOwin(x => x.UseNancy());
        }

        public static void Main() =>
            new WebHostBuilder().UseKestrel().UseStartup<Startup>().Build().Run();
    }
}

Then run dotnet restore, dotnet publish and run it with mono bin/Debug/net451/osx.10.11-x64/publish/NancyApplication.exe.

I have tested this on Ubuntu with mono 4.2.3.

svick
  • 236,525
  • 50
  • 385
  • 514