Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 480
Vahid Amiri Avatar asked May 19 '16 23:05

Vahid Amiri


2 Answers

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

like image 88
Pawel Avatar answered Oct 18 '22 19:10

Pawel


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!

like image 21
Andrei Avatar answered Oct 18 '22 18:10

Andrei