2

I need to publish a .NET Core ASP.NET Website for IIS that targets framework net461.

I've tried:

dotnet publish --runtime active --output "C:\stuff\" --configuration Release

but this results in the project being output as a .exe (along with .dlls of the dotnet core dependencies like Microsoft.AspNetCore.Authorization.dll). I need to publish to IIS on a Windows Server 2008 R2.

"buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true,
    "warningsAsErrors": true
},
"dependencies": {
"Microsoft.AspNetCore.Diagnostics.Elm": "0.1.0",
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"Microsoft.AspNetCore.Authorization": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Hosting": "1.0.0",
"Microsoft.AspNetCore.Hosting.Abstractions": "1.0.0",
"Microsoft.AspNetCore.Http.Extensions": "1.0.0",
"Microsoft.AspNetCore.Localization": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Routing": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.AspNetCore.Session": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Caching.SqlServer": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0"
},

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

Thanks for the help!

Maximilian Riegler
  • 22,720
  • 4
  • 62
  • 71
John-Luke Laue
  • 3,736
  • 3
  • 32
  • 60
  • 1
    an .exe will be part of the published content, in addition to a web.config and some other web artifacts that iis can use. You might need to add some additional steps. See [this article on publishing to iis](https://docs.asp.net/en/latest/publishing/iis.html) for a complete set of instructions. – stephen.vakil Sep 27 '16 at 16:25
  • There's an issue with the --output options, remove it, it will publish in bin/release/net461/publish – agua from mars Sep 27 '16 at 16:49
  • @stephen.vakil is there anyway to publish it as a .dll? if I use framework: netcoreapp1.0, I'm able to get a .dll, but I need to target net461. – John-Luke Laue Sep 27 '16 at 18:03
  • 1
    There may be, but I'm not aware of it. The recommended deployment is to have IIS act as a reverse proxy to Kestrel, which means an `exe` will be involved. A little more info [here](https://docs.asp.net/en/latest/fundamentals/servers.html) though it doesn't precisely answer your question. – stephen.vakil Sep 27 '16 at 18:08
  • @johnluke.laue If you had a pure .Net Core 1.0 application, you could choose to publish it as a `DLL` (Portable application) or `EXE` (Self-contained application). Depending on this, your web.config would have different settings for IIS to run the application. – Ignas Sep 28 '16 at 10:23
  • @Ignas How do I tell if I have a pure .Net Core 1.0 app? Also, how can I "choose" to publish the app as a .DLL? – John-Luke Laue Sep 28 '16 at 22:01

1 Answers1

3

It's perfectly fine to get an exe output for IIS using .Net Core (Self-contained application).

I used following command to publish a test site:

dotnet publish --configuration Release --output "C:\temp\net461-site"

Pointed IIS to C:\temp\net461-site (must have web.config file), changed App Pool CLR version to No Managed Code and the site works.

Ignas
  • 4,092
  • 17
  • 28
  • Thanks for the info! I did what you said, but now I'm getting an IIS HTTP Error 502.5 - Process Failure. I asked a new question regarding this http://stackoverflow.com/questions/39752807/deploy-net-core-asp-net-website-http-error-502-5-process-failure – John-Luke Laue Sep 28 '16 at 16:22
  • @johnluke.laue so do I get my answer accepted or up-voted? :) – Ignas Sep 28 '16 at 16:26
  • I got it working with the EXE, but is there anyway I can make it a DLL? @Ignas – John-Luke Laue Sep 29 '16 at 22:47
  • If you were using pure .Net Core 1.0 you would need to specify `platform` type for the `Microsoft.NETCore.App` dependency. However, this doesn't seem to be compatible with `net461` ... – Ignas Sep 30 '16 at 10:59
  • know if it's compatible with net462? – John-Luke Laue Sep 30 '16 at 16:29
  • Not sure about net462, however it might become possible in .Net Core 2.0 next year - https://blogs.msdn.microsoft.com/dotnet/2016/07/15/net-core-roadmap/ – Ignas Oct 03 '16 at 10:55
  • The 502.5 error comes because ``dotnet publish-iis`` doesn't work any more so the ``web.config`` file is not modified to point to the correct executable. The Azure launcher apparently can not handle the ``%LAUNCHER_PATH%`` and ``%LAUNCHER_ARGS%`` variables and decides to die instead. Modifying the web.config manually works. I'm trying to get around this myself but visual studio resets my web.config on every build :/ – Christian Wattengård Feb 08 '17 at 14:09