Reputation: 247
Trying to migrate the projects from .net core 2.2 to 3.1. In local debug the whole application works correctly. I've tried to publish my application on IIS. After publishing I go to the site url and see the error:
Error 500.31 - ANCM Failed to Find Native Dependencies in IIS
Common solutions to this issue: The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found.
Specific error detected by ANCM: A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in
dotnet --info
command result:
All projects has the target framework .netcoreapp 3.1
, libraries are .netstandart 2.0
.
I've tried re-installing SDK, Visual Studio 2019. I've updated every nuget packages from 2.2 to 3.1.1, that are connected with Microsoft.
Hosting bundle 3.1.1 is also installed. Any ideas how to solve this problem?
UPD. The publish command:
dotnet publish $projectPath -m --no-build -c:$publishConfiguration -o $destinationPath -v q -r $targetPlatform /p:EnvironmentName=$publishEnvironment --self-contained false;
target-platform = win-x64
. The hosting model is InProgress
.
UPD 2. The result of dotnet list package
on solution: https://gist.github.com/AndreiKhotko/60aafeb42566ac3e3fadfab2d0209dde
UPD 3. The ASP.NET Core Diagnostics
generated report: https://gist.github.com/AndreiKhotko/2a193b4121c4399e0a00bfef708140da
UPD 4. Sorry, I haven't specified the whole error message. There is the last part of it (see above for the first part of it):
Failed to run as a self-contained app. If this should be a framework-dependent app, specify the appropriate framework in '*.runtime.config'.
The content of *.runtime.config
:
{
"runtimeOptions": {
"tfm": "netcoreapp3.1",
"includedFrameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "3.1.1"
},
{
"name": "Microsoft.AspNetCore.App",
"version": "3.1.1"
}
],
"configProperties": {
"System.GC.Server": true
}
}
}
Upvotes: 4
Views: 3184
Reputation: 63203
The cause is that dotnet publish
has very ambiguous behaviors when a combination of switches are served.
In your case, --self-contained false
and -r linux-x64
are kind of conflicting to each other. -r linux-x64
forces to generate self-contained binaries, while --self-contained false
seems to remove important runtime dependencies from the final files. It is too bad that the dotnet CLI does not give you a warning/error for that.
If your goal is to use framework dependent deployment, follow the instructions strictly, https://learn.microsoft.com/en-us/dotnet/core/deploying/deploy-with-cli#framework-dependent-deployment and remove -r linux-x64
from your command.
Upvotes: 3