1

I made a ASP.NET Core webapp and wish to deploy it to my raspberry pi and host it using NGINX. Am following the guide provided by Microsoft: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-2.2

and i am stuck at testing the app. This is what I did:

On my Windows PC in which I developed the webapp on, i went to the solution path:

E:\testapp

and ran the command on cmd:

dotnet publish --configuration Release

No errors was found and it was shown that my project L07 that was part of the testapp solution was successful.

But when i tried to test the app by running:

dotnet L07.Views.dll

it returned a fatal error:

A fatal error was encountered. The library 'hostpolicy.dll' required
 to execute the application was not found in 'E:\testapp\L07\bin\Release\net461\publish\'.
 Failed to run as a self-contained app. If this should be a framework-dependent app, 
 add the E:\testapp\L07\bin\Release\net461\publish\L07.Views.runtimeconfig.json
 file specifying the appropriate framework.

. I ignored that and transferred the entire E:\testapp\L07\bin\Release\net461\publish files to my raspberry pi and ran the same dotnet command and it gave me another fatal error which is:

A fatal error occurred, the folder [/usr/local/bin/host/fxr] does not exist

I feel that I am doing many wrong things here, anyone able to advise accordingly, as detailed as possible.

p/s not sure im i am posting this in the correct site

4
  • 1
    Do you compile an self-contained and framework-dependent app? this determines if you need to install the .NET Core SDK/Runtime on the target system or not. Also you can't run applications targeting .NET Framework on Linux unless you target mono (and you don't use any API thats unavailable on mono) Commented Dec 24, 2018 at 20:33
  • @Tseng it is for self-contained. my pi has .NET Core SDK on it Commented Dec 24, 2018 at 20:45
  • Why does then net461 appear in your error message? `E:\testapp\L07\bin\Release\net461\publish` Commented Dec 24, 2018 at 21:28
  • Also post your csproj and what RuntimeIdentifiers/RuntimeIdentifier entries. Without it, its not self-contained. Also you can't self-contain .NET Framework targets, just .NET Core ones Commented Dec 24, 2018 at 21:32

1 Answer 1

2

You need to open your .csproj and add proper runtime identifiers for release. Alternatively you can enter correct runtime identifier from command prompt

This link includes catalog of runtime identifiers

dotnet publish -runtime <yourRID> ...

As it is commented by @Tseng, you need to decide whether you need self-contained or frame dependent application.

If you want to publish self-contained applciation then

dotnet publish -runtime <yourRID> --self-contained ...
Sign up to request clarification or add additional context in comments.

6 Comments

just tried the solution you provided! I encountered the same error again. on my Windows PC, i cd to the ...\net461\any\publish directory and did the command "dotnet L07.Views.dll" . that is correct right?
*.runtimeconfig.json file could not be found in my directory. tried searching in the entire solution, none to be found as well. Tried googling but to no avail in rgds to this as well. // the only .json file i have that was created via dotnet publish is "L07.deps.json"
look at your bin folder :)
yes its not there. bin directory contains "Debug" and "Release" folders which leads to bin/*/net461/
you need to compile your project with .net Core. .Net Framework cannot be deployed on linux environments
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.