Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Publishing to IIS from VS #672

Closed
mikes-gh opened this issue Mar 23, 2016 · 28 comments
Closed

Publishing to IIS from VS #672

mikes-gh opened this issue Mar 23, 2016 · 28 comments
Milestone

Comments

@mikes-gh
Copy link

Used to work.
I am using platform handler 1.2 on IIS 7.5
I am using rc2 vnext latest bits.
I am publishing via file share to iis using right click deploy.
This is the powershell script
When I publish I don't get any runtimes folder in approot.
Also my webconfig doesn't get copied as in my project
It is missing

      <environmentVariables>
        <environmentVariable name="HTTP_PLATFORM_APPL_PATH" value="/reports2" />
      </environmentVariables>
Publishing with publish method [FileSystem]
Publishing files to \\aesdatabase\reports2
Executing command ["C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" -source:contentPath='C:\Users\mikes\AppData\Local\Temp\PublishTemp\Reports274\' -dest:contentPath='\\aesdatabase\reports2' -verb:sync -enableRule:DoNotDeleteRule -retryAttempts:2 -disablerule:BackupRule]

Maybe its because of dotnet cli transition ?

@Tratcher
Copy link
Member

Yes, VS doesn't know about RC2. Try dotnet publish from the command line.

@moozzyk
Copy link
Contributor

moozzyk commented Mar 23, 2016

When using dotnet publish:

  • make sure you include wwwroot in your content otherwise it won't be published
  • add these to your project.json file - this will update your web.config accordingly (or create a new one if one does not exist)

@guardrex
Copy link
Contributor

Hey @moozzyk ... curious b/c I have PowerShell doing my publishing and haven't checked out your dotnet-publish-iis tooling, does dotnet-publish-iis tooling publish Release, or would we still perform a dotnet publish --configuration Release with the tool to get Release output?

@moozzyk
Copy link
Contributor

moozzyk commented Mar 24, 2016

@guardrex - dotnet-publish-iis merely updates (or creates if needed) web.config file of a published application. It just takes the path to the folder the application was published to and goes to wwwroot opens web.config file and makes sure that httpPlatfomHandler (AspNetCoreModule) entries exists and sets the path to the executable.

@guardrex
Copy link
Contributor

@moozzyk I see. I'm looking forward to checking it out. I was just wondering, because dotnet publish still provides Debug bits unless one calls for Release output explicitly. [It's still not clear yet if Debug and Release produce different outputs.]

[EDIT] When I say "yet," I mean "yet to me" 😄

@moozzyk
Copy link
Contributor

moozzyk commented Mar 24, 2016

@guardrex - My understanding is that Debug vs. Release is basically the setting that is eventually being passed to the compiler (csc?). When you do dotnet publish it will compile the project first and this is where the configuration setting is passed. Once the project is compiled the output is being published to the target folder. Finally, postpublish scripts are being run - which is how dotnet-publish-iis is hooked to the pipeline.

@mikes-gh
Copy link
Author

Still doesn't work for me. (And I tired hard)
Does my project json look OK?

{
    "version": "1.0.0-*",

    "commands": {
        "web": "Reports2"
    },
    "compilationOptions": {
        "emitEntryPoint": true,
        "preserveCompilationContext": true
    },
    "dependencies": {
        "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-*",
        "Microsoft.AspNetCore.Authentication.Facebook": "1.0.0-*",
        "Microsoft.AspNetCore.Authentication.Google": "1.0.0-*",
        "Microsoft.AspNetCore.Diagnostics": "1.0.0-*",
        "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0-*",
        "Microsoft.AspNetCore.Hosting": "1.0.0-*",
        "Microsoft.AspNetCore.HttpOverrides": "1.0.0-*",
        "Microsoft.AspNetCore.Identity": "1.0.0-*",
        "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0-*",
        "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-*",
        "Microsoft.AspNetCore.Mvc": "1.0.0-*",
        "Microsoft.AspNetCore.Mvc.Dnx": "1.0.0-*",
        "Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0-*",
        "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-*",
        "Microsoft.AspNetCore.StaticFiles": "1.0.0-*",
        "Microsoft.EntityFrameworkCore.Commands": "1.0.0-*",
        "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-*",
        "Microsoft.EntityFrameworkCore.SqlServer.Design": "1.0.0-*",
        "Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-*",
        "Microsoft.Extensions.Configuration.Json": "1.0.0-*",
        "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-*",
        "Microsoft.Extensions.Logging": "1.0.0-*",
        "Microsoft.Extensions.Logging.Console": "1.0.0-*",
        "Microsoft.Extensions.Logging.Debug": "1.0.0-*",
        "MailKit": "1.3.0-beta7"
    },
    "tools": {
        "dotnet-publish-iis": "1.0.0-*",
        "dotnet-razor-tooling": "1.0.0-*",
        "dotnet-ef": "1.0.0-*"
    },
    "exclude": [
        "wwwroot",
        "node_modules"
    ],
    "frameworks": {
        "netstandardapp1.5": {
            "dependencies": {
                "NETStandard.Library": "1.0.0-*"
            },
            "imports": [
                "dnxcore50",
                "portable-net45+win8"
            ]
        },
        "net451": {
            "dependencies": {
                "hiqpdf": "9.0.0"
            },
            "frameworkAssemblies": {
                "System.ComponentModel": ""
            }


            }
        },
        "publishExclude": [
            "**.user",
            "**.vspscc"
        ],
        "scripts": {
            "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
        }

    }

Running the command

Could not resolve coreclr path

C:\Users\mikes\Projects\Reports2\Main\Reports2\src\Reports2>

@moozzyk
Copy link
Contributor

moozzyk commented Mar 24, 2016

@mikes-gh - I assume restore worked fine. if you try dotnet run does it work? What feeds are you using and what is your dotnet version (dotnet --version)? If I have this information I could try reproducing it.

@mikes-gh
Copy link
Author

@moozzyk thanks for this

I am using vnext feeds

Installed dotnet cli from MSI on repo

C:\Users\mikes\Projects\Reports2\Main\Reports2\src\Reports2>dotnet --version
.NET Command Line Tools (1.0.0-beta-001935)

Product Information:
 Version:     1.0.0-beta-001935
 Commit Sha:  0e92937850

Runtime Environment:
 OS Name:     Windows
 OS Version:  6.1.7601
 OS Platform: Windows
 Runtime Id:  win7-x64

C:\Users\mikes\Projects\Reports2\Main\Reports2\src\Reports2>

dotnet restore ok.
dotnet build ok

C:\Users\mikes\Projects\Reports2\Main\Reports2\src\Reports2>dotnet ef
Could not resolve coreclr path

C:\Users\mikes\Projects\Reports2\Main\Reports2\src\Reports2>
C:\Users\mikes\Projects\Reports2\Main\Reports2\src\Reports2>dnvm list

Active Version           Runtime Architecture OperatingSystem Alias
------ -------           ------- ------------ --------------- -----
       1.0.0-rc1-update1 clr     x64          win
       1.0.0-rc1-update1 clr     x86          win
       1.0.0-rc1-update1 coreclr x64          win
       1.0.0-rc1-update1 coreclr x86          win
       1.0.0-rc2-20221   clr     x86          win
  *    1.0.0-rc2-20221   coreclr x86          win             default




C:\Users\mikes\Projects\Reports2\Main\Reports2\src\Reports2>

@mikes-gh
Copy link
Author

Oh maybe coreclr x86 with dotnet cli x64 mismatch or arch

Whats the consensus on architectures btw. Should I be sticking to x86 all round?

@moozzyk
Copy link
Contributor

moozzyk commented Mar 24, 2016

if you are using dotnet you are not using dnx and therefore what dnvm list shows is irrelevant.

@mikes-gh
Copy link
Author

Didnt realise that.,
So how does an app run get published with dotnet.
Were are the core libraries stored/compiled to. The dotnet magic seems confusing to me.

The reason I ask is because this may be a path thing. When installing dotnet cli via administrator prompt, path variables are not appended to the current user but to adminnistator.

@moozzyk
Copy link
Contributor

moozzyk commented Mar 25, 2016

@mikes-gh - I looked a bit into this today. The Could not resolve coreclr path error is because you have a newer version of dotnet and the publish-iis tool was not updated accordingly to work with this version. There is even more changes in dotnet in this area and we are trying to bring aspnet tools up to date as we speak.

With dotnet you bring the runtime as the package. So, you select your runtime version just by setting it as a dependency in your project.json (dotnet is just a set of tools which are separate from the runtime). The dotnet build/run workflow is actually less magic then it was in dnx - in dnx the application was built at runtime. In dotnet things are more traditional - the application is built (can be done implicitly before you dotnet run or dotnet publish) before it can be run and you have outputs on disk.

If you can run your application with dotnet run then running any tool should also work - all in all dotnet was capable of resolving the runtime for the app so it should be able to resolve the runtime for tools as well - as I said we are looking into fixing this.

@muratg muratg added this to the 1.0.0 milestone Apr 5, 2016
@muratg
Copy link

muratg commented Apr 5, 2016

We'll need to see if this is still an issue in 1.0.0 with the newer VS tooling.

@LeandroPT
Copy link

not working
\cli-samples-master\HelloMvc>dotnet --info
.NET Command Line Tools (1.0.0-rc2-002347)

Product Information:
Version: 1.0.0-rc2-002347
Commit Sha: 5f2183489f

Runtime Environment:
OS Name: Windows
OS Version: 10.0.10586
OS Platform: Windows
RID: win10-x64

dnvm list

Active Version           Runtime Architecture OperatingSystem Alias
------ -------           ------- ------------ --------------- -----
       1.0.0-rc1-final   clr     x64          win
       1.0.0-rc1-final   clr     x86          win
       1.0.0-rc1-final   coreclr x64          win
       1.0.0-rc1-final   coreclr x86          win
       1.0.0-rc1-update1 clr     x64          win
       1.0.0-rc1-update1 clr     x86          win
       1.0.0-rc1-update1 coreclr x64          win
       1.0.0-rc1-update1 coreclr x86          win
       1.0.0-rc1-update2 clr     x86          win
       1.0.0-rc1-update2 coreclr x64          win
       1.0.0-rc2-16357   clr     x86          win
       1.0.0-rc2-20221   clr     x86          win
       1.0.0-rc2-20221   coreclr x64          win
       1.0.0-rc2-20222   clr     x86          win
  *    1.0.0-rc2-20222   coreclr x64          win             default

cli-samples-master\HelloMvc>dotnet publish -o bin\pub

Publishing HelloMvc for .NETCoreApp,Version=v1.0
Project HelloMvc (.NETCoreApp,Version=v1.0) was previously compiled. Skipping compilation.
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.CommandLineUtils, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified.
   at Microsoft.AspNetCore.Tools.PublishIIS.Program.Main(String[] args)
Published to bin\pub
Published 1/1 projects successfully

@guardrex
Copy link
Contributor

@LeandroPT

Side Note: DNX (the runtimes you listed with the dnvm command) are not in use for dotnet cli. DNX is going away and doesn't have a bearing on your issue.

The dotnet-publish-iis tool looks to be involved in this exception. AFAIK the tool is under development (e.g., aspnet/IISIntegration#109).

If you would like to temporarily try publishing the app without the tool, you can follow the steps below.

In project.json, remove ...

"tools": {
  "dotnet-publish-iis": "1.0.0-*"
},
"scripts": {
  "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath%"
}

Confirm your web.config paths are set correctly ...

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <aspNetCore forwardWindowsAuthToken="true" processPath="dotnet" arguments=".\HelloMvc.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" startupTimeLimit="3600" />
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
  </system.webServer>
</configuration>

You'll need to add a logs folder to the project and put a fake text file into it to get the folder to publish (there is an open issue on that bug). Add the logs folder to the content section of project.json. Add the web.config file there, too, since the dotnet-publish-iis tool will not be used with the app ...

"content": [
    "wwwroot",
    "Views",
    "logs",
    "web.config"
],

@mikes-gh
Copy link
Author

I can get dotnet publish to work OK now.

dotnet ef and dotnet razor-tooling both run

However if I try and use dotnet publish-iis
from the command line or in a postpublish script I get

I get

No executable found matching command "dotnet-publish-iis"

I am only building for net461 (no core targets)

Is this because dotnet publish-iis is not cross compiling like the other tools.

@muratg
Copy link

muratg commented Apr 12, 2016

@moozzyk
Copy link
Contributor

moozzyk commented Apr 12, 2016

publish-iis is in a Heisenber state right now. The old publish-iis (in the dotnet-publish-iis package) spits out the config for httpPlatformHandler and not for aspNetCoreModule. On top of that I don't think it accounted for the change where the web.config file was moved out of the wwwroot. The new publish-iis tool (from the Microsoft.AspNetCore.Server.IISIntegration.Tools) cannot work yet since the changes I made to cli to make the scenario where the package name is different from the dll inside the package) have not propagated to our build yet. At the moment I would recommend creating the web.config manually while I am working on sorting things out.

@mikes-gh
Copy link
Author

Ok got it. Bit confusing having a new package different to tool name. Whats the resoning behind that. It might confuse new users.

So to clarify dotnet-publish-iis package is being replaced by Microsoft.AspNetCore.Server.IISIntegration.Tools.

Will that go in the tools section aswell.?

@moozzyk
Copy link
Contributor

moozzyk commented Apr 12, 2016

It will look something like this in project.json:

 "tools": {
        "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*"
    },
    "scripts": {
      "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath%"
    }

There are pros and cons of each approach. We discussed it a lot and we settled on new names for each our tools (not only publish-iis). The work is being tracked here: https://github.com/aspnet/Coherence-Signed/issues/243

@guardrex
Copy link
Contributor

@moozzyk That link 404's.

@mikes-gh
Copy link
Author

Looks like a private repo

@moozzyk
Copy link
Contributor

moozzyk commented Apr 12, 2016

Yeah, forgot about this...

@mikes-gh
Copy link
Author

So to clarify
We'll have

Microsoft.EntityFrameworkCore.Tools
Microsoft.AspNetCore.Mvc.Tools

aswell?

@moozzyk
Copy link
Contributor

moozzyk commented Apr 12, 2016

Yes, something along these lines.

@LeandroPT
Copy link

@guardrex

I am totally lost here....

Trying to get this thing running in AppService@Azure.. as far as i see i am missing a web.config or a mess.config :) somewhere...

I installed on KUDU .net cli, compiled the app, dotnet publish, changed the web.config as above.

I can start it manually (same as aspNetCore node), it works, and listens on 5000

However i am definitely missing something here...

@muratg
Copy link

muratg commented May 19, 2016

Closing this one, if you are still hitting this issue, please file another bug.

@muratg muratg closed this as completed May 19, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants