10

I have an ASP.NET Core RC2 Project, I'm trying to publish it to IIS and the command dotnet publish-iis ALWAYS gives:

Asp.Net Core IIS Publisher
Usage: dotnet publish-iis [arguments] [options]
Arguments:
  <PROJECT>  The path to the project (project folder or project.json) being published. If empty the current directory is used.
Options:
  -h|--help                   Show help information
  --publish-folder|-p         The path to the publish output folder
  -f|--framework <FRAMEWORK>  Target framework of application being published

Is there even an example of how this works? How do I pass the parameters? It never works...

Vahid Amiri
  • 10,769
  • 13
  • 68
  • 113

2 Answers2

9

--publish-folder and --framework parameters are required. If you don't provide these parameters the tool will displays the usage.

Having said that it is not actually expected to run this tool on its own. What publish-iis does is it merely tweaks the web.config file of an already published app (or creates a new web.config if one does not exist) so that IIS/IISExpress can find the application to start. In other words you have to publish your application first and then publish-iis just massages it a little bit. As a result the expected usage is to configure so that it runs as a postpublish script:

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

I described the publish-iis tool in more details in this post on running Asp.NET Core apps with IIS

Pawel
  • 31,342
  • 4
  • 73
  • 104
  • But this doesn't generate a `web.config` in wwwroot. Is this expected? I thought web.config is required both in project root and in wwwroot. – Vahid Amiri May 19 '16 at 23:38
  • 2
    This is expected (https://github.com/aspnet/Announcements/issues/173). The default location for web.config file is now your approot and not wwwroot. Also, why having 2 web.config files would be useful? – Pawel May 19 '16 at 23:56
  • The name isn't confusing at all . By the way great write-up. The aspnet docs are great but this section especially makes no sense in the docs. – josullivan Sep 13 '16 at 19:49
6

For ASP.NET Core 1.1. Key pieces in project.json are:

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final"
  },

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

Worked great for me!

Andrei
  • 42,814
  • 35
  • 154
  • 218