Reference a Full Framework Library Project from ASP.NET Core MVC Web Application (RC2)?

后端 未结 2 1977
暗喜
暗喜 2021-01-02 05:48

I\'m currently using ASP.NET Core MVC RC2 which is suppose to support referencing a full framework library Project from a Core MVC Web Application Project. But I can\'t see

相关标签:
2条回答
  • There is a template that allows you to target the full .NET framework - sorry, can't post an image yet, but you can go to: Templates -> Visual C# -> Web -> ASP.NET Core Web Application (.NET Framework)

    Note that you can specify the version of the .NET Framework from the dropdown above (as per usual).

    This will change your project.json to:

    "frameworks": {
    "net461": { }
    }
    

    (depending on the framework version that you've selected). You will now be able to add a reference to your class library.

    "frameworks": {
        "net461": {
        "dependencies": {
        "ClassLibrary1": {
            "target": "project"
            }
         }
       }
    }
    
    0 讨论(0)
  • 2021-01-02 06:26

    Following Ron C's steps here's the complete project.json for a web api project I just tested and it worked.

    {
      "dependencies": {
        "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": {
        "net461": {
          "imports": [
            "dotnet5.6",
            "portable-net45+win8"
          ],
          "frameworkAssemblies": {
            "System.Data": "4.0.0.0"
          }
        }
      },
    
      "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%" ]
      }
    }
    
    0 讨论(0)
提交回复
热议问题