在类库项目

时间:2016-05-09 11:43:08

标签: compilation asp.net-core .net-assembly

我创建了一个ASP.NET Core应用程序:

 {
      "version": "1.0.0-*",
      "compilationOptions": {
        "emitEntryPoint": true
      },

      "dependencies": {
        "EntityFramework.Commands": "7.0.0-beta8",
        "EntityFramework.SqlServer": "7.0.0-beta8",
        "EntityFramework.Core": "7.0.0-beta8",
        "EntityFramework.SqlServer.Design": "7.0.0-beta8",
        "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
        "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
        "Microsoft.AspNet.Mvc.Abstractions": "6.0.0-rc1-final",
        "Microsoft.AspNet.Mvc.Core": "6.0.0-rc1-final",
        "Microsoft.AspNet.Mvc.DataAnnotations": "6.0.0-rc1-final",
        "Microsoft.AspNet.Mvc.WebApiCompatShim": "6.0.0-rc1-final",
        "Microsoft.AspNet.Mvc.ViewFeatures": "6.0.0-rc1-final",
        "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
        "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
        "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
        "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
        "System.IdentityModel.Tokens.Jwt": "5.0.0-rc1-211161024",
        "Microsoft.IdentityModel.Protocols": "2.0.0-rc1-211161024",
        "ClassLibrary1": "1.0.0-*",
        "InviteMoi.BLL": "1.0.0-*",
        "InviteMoi.DAL": "1.0.0-*"
      },

      "commands": {
        "web": "Microsoft.AspNet.Server.Kestrel",
        "ef": "EntityFramework.Commands"
      },

      "frameworks": {
        "dnx451": {
          "dependencies": {
            "Microsoft.AspNet.Identity.EntityFramework": "2.2.1",
            "Microsoft.AspNet.Identity.Owin": "2.2.1",
            "Microsoft.AspNet.WebApi.Owin": "5.2.3",
            "Microsoft.Owin.Cors": "3.0.1",
            "Microsoft.Owin.Host.SystemWeb": "3.0.1",
            "Owin": "1.0.0",
            "Thinktecture.IdentityModel": "3.6.1",
            "Thinktecture.IdentityModel.Client": "4.0.1"
          },
          "frameworkAssemblies": {
            "System.Web": "4.0.0.0"
          }
        }

      },

      "exclude": [
        "wwwroot",
        "node_modules"
      ],
      "publishExclude": [
        "**.user",
        "**.vspscc"
      ]
    }

然后我添加了一个单元测试项目:

 {
  "version": "1.0.0-*",
  "description": "InviteMoi.Test Class Library",
  "authors": [ "lamloumiafif" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",
  "frameworks": {
    "net451": {
      "dependencies": { 

      }
    },

    "dotnet5.4": {
      "dependencies": {

        "Microsoft.CSharp": "4.0.1-beta-23516",
        "System.Collections": "4.0.11-beta-23516",
        "System.Linq": "4.0.1-beta-23516",
        "System.Runtime": "4.0.21-beta-23516",
        "System.Threading": "4.0.11-beta-23516"
      }
    }
  },
  "dependencies": { 
    "NUnit": "3.2.1",
    "EntityFramework.InMemory": "7.0.0-rc1-final",
    "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
    "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final",
    "InviteMoi.BLL": "1.0.0-*",
    "InviteMoi.DAL": "1.0.0-*"
  }
}

问题是当我想在测试项目中添加Web应用程序的引用时,它不起作用,并且异常表示不会出现更高版本的ASP.NET Core。< / p>

那么我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

单元测试项目中的

。删除dotnet5.4并将net451更改为dnx451,就像在应用程序中一样。单元测试项目的应用程序与Web应用程序相同