sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Cannot run published application without %DOTNET_HOME%

Open moozzyk opened this issue 10 years ago • 12 comments

If I publish an application and run it as a user who does not have DOTNET_HOME env variable (think IIS) it will fail to start due to the "Could not resolve coreclr path" error:

c:\Temp\WebApp6IIS>WebApplication6.exe
Tracing enabled
Loaded library from c:\Temp\WebApp6IIS\hostpolicy.dll
Calling host entrypoint from library at own dir c:\Temp\WebApp6IIS
Could not resolve coreclr path

Here is the published output:

c:\Temp\WebApp6IIS>dir
 Volume in drive C is OSDisk
 Volume Serial Number is 625C-A0E8

 Directory of c:\Temp\WebApp6IIS

01/22/2016  11:00 AM    <DIR>          .
01/22/2016  11:00 AM    <DIR>          ..
01/22/2016  10:55 AM                51 hosting.json
01/16/2016  12:59 AM           549,376 hostpolicy.dll
01/20/2016  03:31 PM           274,432 libuv.dll
01/22/2016  11:00 AM    <DIR>          logs
01/20/2016  03:31 PM            47,104 Microsoft.AspNet.Authentication.dll
01/20/2016  02:32 PM            30,720 Microsoft.AspNet.Cryptography.Internal.dll
01/20/2016  02:32 PM            12,288 Microsoft.AspNet.DataProtection.Abstractions.dll
01/20/2016  02:32 PM           130,560 Microsoft.AspNet.DataProtection.dll
01/20/2016  02:32 PM             5,120 Microsoft.AspNet.FileProviders.Abstractions.dll
01/20/2016  03:31 PM            15,872 Microsoft.AspNet.FileProviders.Physical.dll
01/20/2016  02:32 PM             8,192 Microsoft.AspNet.Hosting.Abstractions.dll
01/20/2016  03:31 PM            57,344 Microsoft.AspNet.Hosting.dll
01/20/2016  02:32 PM             5,120 Microsoft.AspNet.Hosting.Server.Abstractions.dll
01/20/2016  02:32 PM            51,200 Microsoft.AspNet.Http.Abstractions.dll
01/20/2016  03:31 PM            64,512 Microsoft.AspNet.Http.dll
01/20/2016  02:32 PM            26,112 Microsoft.AspNet.Http.Extensions.dll
01/20/2016  02:32 PM            17,408 Microsoft.AspNet.Http.Features.dll
01/20/2016  03:31 PM            15,360 Microsoft.AspNet.IISPlatformHandler.dll
01/20/2016  03:31 PM           219,648 Microsoft.AspNet.Server.Kestrel.dll
01/20/2016  03:31 PM            34,816 Microsoft.AspNet.WebUtilities.dll
01/20/2016  02:32 PM             5,632 Microsoft.Extensions.Configuration.Abstractions.dll
01/20/2016  03:31 PM            10,240 Microsoft.Extensions.Configuration.CommandLine.dll
01/20/2016  03:31 PM            14,848 Microsoft.Extensions.Configuration.dll
01/20/2016  03:31 PM            10,240 Microsoft.Extensions.Configuration.EnvironmentVariables.dll
01/20/2016  03:31 PM             5,632 Microsoft.Extensions.Configuration.FileExtensions.dll
01/20/2016  03:31 PM            13,824 Microsoft.Extensions.Configuration.Json.dll
01/20/2016  02:32 PM            23,552 Microsoft.Extensions.DependencyInjection.Abstractions.dll
01/20/2016  03:31 PM            27,136 Microsoft.Extensions.DependencyInjection.dll
01/20/2016  02:32 PM            26,112 Microsoft.Extensions.Logging.Abstractions.dll
01/20/2016  03:31 PM            17,408 Microsoft.Extensions.Logging.Console.dll
01/20/2016  02:32 PM             8,192 Microsoft.Extensions.Logging.dll
01/20/2016  02:32 PM            12,288 Microsoft.Extensions.Options.dll
01/20/2016  02:32 PM            14,848 Microsoft.Extensions.PlatformAbstractions.dll
01/20/2016  02:32 PM            16,896 Microsoft.Extensions.Primitives.dll
01/20/2016  03:31 PM             9,216 Microsoft.Extensions.WebEncoders.dll
01/20/2016  02:32 PM            52,736 Microsoft.Net.Http.Headers.dll
01/19/2016  10:55 AM            27,376 Microsoft.Win32.Primitives.dll
01/19/2016  10:55 AM            53,984 Microsoft.Win32.Registry.dll
01/22/2016  10:57 AM    <DIR>          mywebroot
01/19/2016  10:42 AM           449,024 Newtonsoft.Json.dll
01/19/2016  10:55 AM            20,168 System.AppContext.dll
01/20/2016  02:32 PM            24,760 System.Buffers.dll
01/19/2016  10:55 AM            92,920 System.Collections.Concurrent.dll
01/19/2016  10:55 AM           104,136 System.Collections.dll
01/19/2016  10:55 AM            89,336 System.Collections.NonGeneric.dll
01/19/2016  10:55 AM            21,720 System.ComponentModel.dll
01/19/2016  10:55 AM            72,376 System.Console.dll
01/19/2016  11:54 AM            21,232 System.Diagnostics.Contracts.dll
01/19/2016  10:55 AM            36,064 System.Diagnostics.Debug.dll
01/19/2016  11:54 AM            24,336 System.Diagnostics.DiagnosticSource.dll
01/19/2016  11:54 AM            22,776 System.Diagnostics.StackTrace.dll
01/19/2016  10:55 AM            22,248 System.Diagnostics.Tools.dll
01/19/2016  10:55 AM            56,568 System.Diagnostics.TraceSource.dll
01/19/2016  11:54 AM            36,584 System.Diagnostics.Tracing.dll
01/19/2016  10:55 AM           112,344 System.Dynamic.Runtime.dll
01/19/2016  11:54 AM            20,896 System.Globalization.Calendars.dll
01/19/2016  10:55 AM            20,688 System.Globalization.dll
01/19/2016  11:54 AM            36,096 System.Globalization.Extensions.dll
01/19/2016  10:55 AM           109,784 System.IO.Compression.dll
01/19/2016  10:55 AM            24,232 System.IO.dll
01/19/2016  10:55 AM           119,152 System.IO.FileSystem.dll
01/19/2016  10:55 AM            22,432 System.IO.FileSystem.Primitives.dll
01/19/2016  11:54 AM            50,416 System.IO.FileSystem.Watcher.dll
01/19/2016  10:55 AM           103,088 System.Linq.dll
01/19/2016  10:55 AM           462,200 System.Linq.Expressions.dll
01/19/2016  11:54 AM           243,904 System.Net.Http.dll
01/19/2016  11:54 AM           311,512 System.Net.Primitives.dll
01/19/2016  11:53 AM            30,936 System.Net.WebSockets.dll
01/19/2016  11:54 AM           157,408 System.Numerics.Vectors.dll
01/19/2016  10:55 AM            49,872 System.ObjectModel.dll
01/19/2016  10:55 AM           121,032 System.Private.Uri.dll
01/19/2016  10:55 AM            21,192 System.Reflection.dll
01/19/2016  10:55 AM            20,704 System.Reflection.Emit.dll
01/19/2016  10:55 AM            20,752 System.Reflection.Emit.ILGeneration.dll
01/19/2016  11:54 AM            20,752 System.Reflection.Emit.Lightweight.dll
01/19/2016  11:54 AM            20,720 System.Reflection.Extensions.dll
01/19/2016  10:55 AM            20,728 System.Reflection.Primitives.dll
01/19/2016  11:53 AM            28,416 System.Reflection.TypeExtensions.dll
01/19/2016  10:55 AM            20,736 System.Resources.ResourceManager.dll
01/19/2016  10:55 AM            39,608 System.Runtime.dll
01/19/2016  10:55 AM            81,128 System.Runtime.Extensions.dll
01/19/2016  11:58 AM            22,744 System.Runtime.Handles.dll
01/19/2016  10:55 AM            33,528 System.Runtime.InteropServices.dll
01/19/2016  10:55 AM            31,560 System.Runtime.InteropServices.RuntimeInformation.dll
01/19/2016  11:54 AM            71,904 System.Runtime.Numerics.dll
01/19/2016  11:53 AM            58,744 System.Security.Claims.dll
01/19/2016  10:55 AM            69,568 System.Security.Cryptography.Algorithms.dll
01/19/2016  11:54 AM            85,920 System.Security.Cryptography.Cng.dll
01/19/2016  11:54 AM            66,816 System.Security.Cryptography.Csp.dll
01/19/2016  11:54 AM            55,736 System.Security.Cryptography.Encoding.dll
01/19/2016  10:55 AM            45,504 System.Security.Cryptography.Primitives.dll
01/19/2016  11:54 AM           133,080 System.Security.Cryptography.X509Certificates.dll
01/19/2016  11:53 AM            21,896 System.Security.Principal.dll
01/19/2016  10:55 AM            80,296 System.Security.Principal.Windows.dll
01/19/2016  11:54 AM            20,688 System.Text.Encoding.dll
01/19/2016  10:55 AM            20,736 System.Text.Encoding.Extensions.dll
01/19/2016  10:42 AM            64,232 System.Text.Encodings.Web.dll
01/19/2016  11:54 AM           113,560 System.Text.RegularExpressions.dll
01/19/2016  10:55 AM            49,856 System.Threading.dll
01/19/2016  10:55 AM            29,936 System.Threading.Overlapped.dll
01/19/2016  11:54 AM            26,328 System.Threading.Tasks.dll
01/19/2016  11:54 AM            24,840 System.Threading.Tasks.Extensions.dll
01/19/2016  10:55 AM            20,704 System.Threading.Thread.dll
01/19/2016  10:55 AM            20,720 System.Threading.ThreadPool.dll
01/19/2016  11:54 AM            20,184 System.Threading.Timer.dll
01/19/2016  10:55 AM           601,312 System.Xml.ReaderWriter.dll
01/19/2016  10:55 AM           111,984 System.Xml.XDocument.dll
01/22/2016  11:15 AM            11,264 WebApplication6.dll
01/16/2016  12:59 AM           427,520 WebApplication6.exe
01/22/2016  11:15 AM            15,872 WebApplication6.pdb
01/22/2016  10:57 AM    <DIR>          wwwroot
             108 File(s)      7,657,403 bytes
               5 Dir(s)  80,940,535,808 bytes free

moozzyk avatar Jan 22 '16 20:01 moozzyk

Can you share your project.json?

You don't appear to have the runtime in your publish output. Seems like putting a reference to the runtime/StdLib there could solve this?

brthor avatar Jan 22 '16 20:01 brthor

Here is the project.json

{
  "webroot": "wwwroot",
  "version": "1.0.0-*",

  "compilationOptions": { "emitEntryPoint": true },

  "dependencies": {
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-*",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
    "Microsoft.AspNet.Authentication": "1.0.0-*",
    "Microsoft.Extensions.Logging.Console": "1.0.0-*"
  },

  "tools": {
    "dotnet-publish-iis": "1.0.0-*"
  },

  "frameworks": {
    "dnxcore50": { },
    "dnx451": { }
  },

  "content": [
    "wwwroot",
    "hosting.json"
  ],

  "exclude": [
    "node_modules",
    "bower_components"
  ],
  "publishExclude": [
    "**.user",
    "**.vspscc"
  ],

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

If adding a reference to runtime fixes the issue - shouldn't this be a dotnet publish option? (like include runtime?)

moozzyk avatar Jan 22 '16 20:01 moozzyk

Why not reference NETStandard.Library? It contains the reference to the runtime. I'm not sure what the eventual plan is there, but it should get you unblocked.

brthor avatar Jan 22 '16 20:01 brthor

Yes, I will reference the NETStandard library for now, and this is not a problem. I was trying to say that having the option in dotnet publish makes it more obvious whether the runtime is getting published or not. The issue is that is quite hard to troubleshoot and figure out if you are running behind Http Platform Handler (IIS) - because you run the published app from command line and it works and you run exactly the same app from with IIS and it does not.

When troubleshooting I the only thing I could found was an entry like this from Http Platform Handler:

Process '15888' failed to start. Port = 21561, Error Code = '-2147023829'.

I assume -2147023829 is HRESULT 8007042B which when you google it does not give you any hint about what's going (I don't even know if it is the exit code of the app itself or an error code specific to Http Platform Handler)

moozzyk avatar Jan 22 '16 20:01 moozzyk

Another related question - if I have a reference to NETStandard library in my project.json - how do I publish without runtime?

moozzyk avatar Jan 22 '16 21:01 moozzyk

@richlander @glennc @DamianEdwards @piotrpMSFT @davidfowl It feels like customers could easily run into this situation themselves. Is there something else we can do here to improve the experience?

danroth27 avatar Jan 22 '16 23:01 danroth27

This isn't blocking, but the user experience can be poor.

danroth27 avatar Jan 25 '16 17:01 danroth27

This needs some thought.

@schellap, you're creating Host nupkgs. What is your plan for how they are referenced by user projects? What is your plan for managing host/runtime relationship?

@moozzyk publishing without a runtime is really the 'publish to machine with shared framework' scenario, right? In this case, not only the runtime but NETStandard.Library need to get cleaned out. Isn't this what dotnet-publish-iis is supposed to do?

TheRealPiotrP avatar Jan 27 '16 10:01 TheRealPiotrP

@piotrpMSFT - publishing without a runtime is a scenario where the framework is shared. publish-iis is not touching any of the published files but web.config. Its only task (at least at the moment) is to create or update the web.config so that it points to the app based on the published output and configured webroot. Teaching publish-iis to distinguish runtime libraries from application libraries feels wrong and error prone. Also note that publish-iis is only specific to web apps and being able to publish without a runtime applies to all kinds of apps.

moozzyk avatar Jan 27 '16 17:01 moozzyk

@schellap, you're creating Host nupkgs. What is your plan for how they are referenced by user projects?

The host will be dropped by dotnet compile/publish for the default case. When the user specifies dotnet publish --no-host, then they are responsible for bringing in a version of the host through either the project.json and renaming it to app.exe or specify to publish (TBD) dotnet publish --host-package --host-version Version if we didn't want to burden the user with the renaming... thoughts?

What is your plan for managing host/runtime relationship?

An old host could get out of sync with a newer runtime (new properties or changed meanings) but I also think the user should have control over the runtime. I don't like the idea of host declaring a dependency on the Runtime. The user should bring in a host (through publish or explicitly) and runtime to the machine and specify to the host what runtime to use. Currently this is using APP_DIR and then, DOTNET_HOME, but we can remove DOTNET_HOME and allow a runtime.config.json (https://github.com/dotnet/cli/blob/master/Documentation/specs/runtime-configuration-file.md) override to use a shared runtime path which will win over APP_DIR.

Cc @ericstj @blackdwarf Cc @gkhanna79

schellap avatar Jan 27 '16 20:01 schellap

Is this still reproing on the latest bits? I did not run into it...

thesmithee avatar Jul 27 '16 04:07 thesmithee

Fixed long ago...

TheRealPiotrP avatar Jul 27 '16 22:07 TheRealPiotrP