iis is immediately closed after publishing asp.net

2020-04-11 10:25发布

问题:

IIS Express is immediately closed after i try to debug my asp.net core project under it. i am using visual studio 2015 update 3.

Thanks in advance

my packages are fine but for sake of completness here is project.json:

 "dependencies": {
"Microsoft.NETCore.App": {
  "version": "1.1.0",
  "type": "platform"
},
"Microsoft.AspNetCore.Authentication.JwtBearer": "1.1.0",
"Microsoft.AspNetCore.Mvc": "1.1.0",
"Microsoft.AspNetCore.Routing": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-preview1-final",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"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.1.0",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final"
}, 
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
},
"frameworks": {
   "netcoreapp1.1.0": {     
    }
},
 "buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
 "runtimeOptions": {
"configProperties": {
  "System.GC.Server": true
  }
},

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

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

and this is my startup class:

  loggerFactory.AddConsole(Configuration.GetSection("Logging"));
  loggerFactory.AddDebug();
  app.UseMvc();

回答1:

I could reproduce this behaviour and I am pretty sure this is caused by missing .NET Core 1.1 runtime libraries. When you go to C:\Program Files\dotnet\shared\Microsoft.NETCore.App you probably won't see the '1.1.0' directory.

Go to https://www.microsoft.com/net/download/core and install the SDK library (select Current and SDK).

N.B. If you did try (as I suggested in one of my comments) to remove the "type": "platform" line (and adding the runtimes part (depending on your windows version) then you'll see it won't crash. Without having to install the runtime / SDK.