【问题标题】:.Net Framework + Core Template application deploy to cloud Foundary.Net Framework + Core Template 应用部署到云端 Foundry
【发布时间】:2017-03-23 20:49:56
【问题描述】:

大家好,我正在使用 .Net 框架开发 ASP.NET 应用程序核心模板。我必须将我的应用程序发布到 Cloud Foundry。但不幸的是,我的应用程序崩溃了,无法部署到 Cloud Foundry 环境。如果遇到同样的情况并解决了问题,请提出建议。谢谢。我浏览了一些网站并尝试如下修改仍然无法部署。我正在使用 .NetCoreBuild 包进行部署。

Program.cs:-

 public static void Main(string[] args)
        {
            var config = new ConfigurationBuilder()
               .AddCommandLine(args)
               .Build();
            var host = new WebHostBuilder()
                .UseKestrel()
               //.UseContentRoot(Directory.GetCurrentDirectory())
               //.UseIISIntegration()
               .UseConfiguration(config)
                        .UseStartup<Startup>()
                        .Build();

            host.Run();
        }
Project.Json:-

{
  "buildOptions": {
    "copyToOutput": {
      "include": [
        "wwwroot",
        "**/*.cshtml",
        "appsettings.json",
        "web.config"
      ],
      "exclude": [
        "bin",
        "obj"
      ]
    },
    "debugType": "portable",
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "web.config"
    ],
    "exclude": [
      "bin",
      "obj"
    ]
  },

  "dependencies": {
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.2",
    "Microsoft.AspNetCore.Routing": "1.0.2",
    "Microsoft.AspNetCore.Mvc": "1.0.2",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview4-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.StaticFiles": "1.0.1",
    "Microsoft.Extensions.Configuration.CommandLine": "1.0.1",
    "Microsoft.Extensions.Configuration.Json": "1.0.1",
    "Microsoft.Extensions.Logging": "1.0.1",
    "Microsoft.Extensions.Logging.Console": "1.0.1",
    "Microsoft.Extensions.Logging.Debug": "1.0.1",
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.3"
    },
    "Microsoft.AspNetCore.Diagnostics": "1.0.1",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.1",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
    "Microsoft.Extensions.Configuration": "1.1.0"
  },

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

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

  "scripts": {
    "precompile": [ "dotnet bundle" ]
  },

  "tools": {
    "BundlerMinifier.Core": "2.2.301",
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview4-final"
  },

  "version": "1.0.3"
}

【问题讨论】:

    标签: asp.net-core cloud-foundry asp.net-core-webapi


    【解决方案1】:

    在您指定的 project.json 文件中:

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

    net461 指的是 .NET Framework 4.6.1,但 .NET Core buildpack 仅支持 .NET Core。使用netcoreapp1.0 而不是net461,像这样:

    "frameworks": {
      "netcoreapp1.0": { }
    }
    

    【讨论】:

    • 感谢 Daniel 的回复,但我正在使用带有核心模板的 .Net 框架。在这种情况下,请建议我应该使用哪个构建包。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-20
    相关资源
    最近更新 更多