2

I've created a new ASP.NET Core project and a class library for it in VS 2015 (Update 3).

This is how project.json looks like:

    {
      "version": "1.0.0-*",

      "dependencies": {
        "NETStandard.Library": "1.6.0"
      },

      "frameworks": {
        "netstandard1.6": {
          "imports": "dnxcore50"
        }
      }
    }

And this is a project.json of the ASP.NET Project:

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "Areas/**/Views",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

Now I can't add my class library to my site as 'dependency can't be resolved'.

1 Answer 1

1

I didn't see a reference to your library in your application's dependencies section. If your library and your application are in the same solution, make sure you use target: project like so:

project.json of ASP.NET Core project:

"dependencies": {
    ...
    "MyLibrary": {
        "version": "1.0.0",
        "target": "project"
    }
}

Otherwise, NuGet will look for your library as a package instead of looking in the solution.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you @Nate Barbettini, it has been helpful. Now my ASP.NET Core projects builds fine but I'm still having an issue with Resharper. It still doesn't see libraries. By any chance do you know a cure for this?
@alexxjk That's a known issue with Resharper unfortunately. You'll either have to wait for the next release, or get the beta (EAP) version.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.