Reputation: 423
I have a .Net Core web application targeting net461 Framework. It was originally producing an .EXE and working fine when deploying to IIS. I want to change to a portable app, so I changed "buildOptions" in ProjectJson as follows:
"buildOptions": {
"emitEntryPoint": false,
"preserveCompilationContext": true,
"debugType": "portable"
},
Now when I compile I get a DLL and it runs fine in IIS Express, but when I publish to IIS and change the web.config aspnetcore element to:
<aspNetCore processPath="dotnet" arguments=".\myWebApp.dll"
stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout"
forwardWindowsAuthToken="false" />
The project fails to run and I see "Failed to start process with commandline '"dotnet" MyWebApp.dll', ErrorCode = '0x80004005'" in the application event log.
Attempting to run from command line with "dotnet mywebapp.dll" results in:
A fatal error was encountered. The library 'hostpolicy.dll' required to
execute the application was not found in 'C:\inetpub\wwwroot\ETimeCore2'.
So I found and copied hostpolicy.dll to the directory and now get:
Could not resolve CoreCLR path. For more details, enable tracing by setting
CORE HOST_TRACE environment variable to 1
I did set the CORE HOST_TRACE to 1 and got a verbose response of all the dlls being loaded with just that one error (above) at the end so it added no value.
Any idea what I am doing wrong?? I prefer a DLL to an EXE because to publish changes when an .EXE, you have to recycle the app pool first which is a real pain.
Upvotes: 3
Views: 4019
Reputation: 49789
You cannot use dotnet mywebapp.dll
if disable "emitEntryPoint".
emitEntryPoint
indicates whether the project is a console application vs. a library. From sources:
if (framework.IsDesktop() && compilerOptions.EmitEntryPoint.GetValueOrDefault())
{
OutputExtension = FileNameSuffixes.DotNet.Exe;
}
In your case the framework.IsDesktop()
is true, as your target framework is net461
, that is .NET Framework , not .NET Core. That's way you get .exe
as output if enable emitEntryPoint
.
Actually error "The library 'hostpolicy.dll' required to execute the application was not found in " right now means the following (see http://github.com/dotnet/cli/issues/2859 issue):
dotnet.exe cannot find the entry point in mywebapp.dll
Upvotes: 2