在asp.net核心RC2中使用swagger

时间:2016-05-30 19:23:03

标签: asp.net asp.net-core-1.0 swashbuckle

我正在将项目从ASP.NET RC1迁移到RC2,但有些软件包无法运行。 VS抱怨无法解决问题。要添加的正确包/版本是什么

  "Swashbuckle.SwaggerGen": "6.0.0-rc1-final",
  "Swashbuckle.SwaggerUi": "6.0.0-rc1-final"

以下是整个project.json文件(如果缺少某些内容)。最后3个包失败并出现相同的错误(The dependency XXX >= YYY could not be resolved

{ "buildOptions": { "emitEntryPoint": true, "preserveCompilationContext": true }, "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1-rc2-24027", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final", "Microsoft.AspNetCore.Mvc.Core": "1.0.0-rc2-final", "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final", "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final", "Microsoft.Extensions.Logging": "1.0.0-rc2-final", "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final", "Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final", "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0-rc2-final", "RestSharp": "105.2.3", "Flurl.Http": "0.7.0", "Microsoft.EntityFrameworkCore.Tools": { "version": "1.0.0-preview1-final", "type": "build" }, "Swashbuckle.SwaggerGen": "6.0.0-rc1-final", "Swashbuckle.SwaggerUi": "6.0.0-rc1-final", "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final" }, "tools": { "Microsoft.AspNetCore.Server.IISIntegration.Tools": { "version": "1.0.0-preview1-final", "imports": "portable-net45+win8" }, "Microsoft.EntityFrameworkCore.Tools": { "version": "1.0.0-preview1-3002702", "imports": [ "portable-net45+win8", "portable-net4+win8" ] }, "Microsoft.Extensions.SecretManager.Tools": { "version": "1.0.0-preview1-final", "imports": "portable-net45+win8" } }, "frameworks": { "net452": { "frameworkAssemblies": { "System.Runtime.Serialization": "4.0.0.0", "System.ServiceModel": "4.0.0.0", "System.Net.Http": "4.0.0.0" } } }, "runtimeOptions": { "gcServer": true }, "publishOptions": { "include": [ "wwwroot", "appsettings.json", "web.config" ] } }

2 个答案:

答案 0 :(得分:3)

适用于.net 4.5。检查这个project.json

{
   "dependencies": {
        "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
        "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
        "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
        "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
        "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0-rc2-final",
        "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
        "Microsoft.Extensions.Logging": "1.0.0-rc2-final",
        "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
        "Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
        "Swashbuckle.SwaggerGen": "6.0.0-beta9",
        "Swashbuckle.SwaggerUi": "6.0.0-beta9"
},

"tools": {
       "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
         "version": "1.0.0-preview1-final",
         "imports": "portable-net45+win8+dnxcore50"
       }
},

"frameworks": {
       "net452": { }
},

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

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

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

答案 1 :(得分:1)

您不能在项目json中混用rc1和rc2包。如果你需要在项目中使用swagger,他们已经发布了.net core rc2的新版本。

更新, " Swashbuckle.SwaggerGen":" 6.0.0-rc1-final", " Swashbuckle.SwaggerUi":" 6.0.0-rc1-final"

要, " Swashbuckle.SwaggerGen":" 6.0.0-beta9", " Swashbuckle.SwaggerUi":" 6.0.0-beta9"