Vahid Amiri
Vahid Amiri

Reputation: 11127

dotnet publish-iis doesn't work

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...

Upvotes: 10

Views: 8421

Answers (2)

Andrei
Andrei

Reputation: 44700

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!

Upvotes: 6

Pawel
Pawel

Reputation: 31620

--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

Upvotes: 9

Related Questions