Search code examples
visual-studio-2015class-library

Create Project Reference to net451 xproj Class Library from ASP.NET 4.6


I need to debug my class library. In Visual Studio 2015, I created an ASP.NET 4.6.1 web application. Within the same solution, I created a new Class Library (Package) project (xproj file).

This class library only uses the net451 framework, as you can see from my project.json file.

{
  "version": "1.0.0-*",
  "description": "Services Class Library",
  "authors": [ "David" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",
  "frameworks": {
    "net451": {
      "dependencies": {
        "EntityFramework6.Npgsql": "3.1.0",
        "Microsoft.AspNet.Identity.EntityFramework": "2.0.0",
        "Microsoft.CSharp": "4.0.1",
        "Newtonsoft.Json": "9.0.1",
        "System.Collections": "4.0.11",
        "System.ComponentModel": "4.0.0",
        "System.ComponentModel.Annotations": "4.1.0",
        "System.Linq": "4.1.0",
        "System.Runtime": "4.1.0",
        "System.Threading": "4.0.11"
      },
      "frameworkAssemblies": {
        "System.IdentityModel": "4.0.0.0"
      }
    }
  },
  "dependencies": {
    "System.IdentityModel.Tokens.Jwt": "4.0.2.206221351"
  }
}

Within the site, I can reference the library if I browse to the DLL. But I cannot create a project reference. Without the project reference, I cannot seem to debug the library while running the site. Is this even possible? I'm not doing any .NET Core stuff as you can see. And I don't care about the ability for the library to be a NuGet package. I sense that if I could create a csproj class library instead of an xproj library, then this wouldn't be an issue, but I can't find a way to do that.


Solution

  • Before posting the question, I took a few more minutes to try to create a csproj project. I discovered that you can do so when creating a Class Library under the Visual C# Windows templates instead of the Web templates. I removed my xproj project from the solution, moved the files elsewhere on my drive, created a new project with the same name, copied the files back over and restored the references, and all was good. I can now step into the library functions while debugging.