问题
I'm using Visual Studio 2019 to publish a self contained .net core 2.1 app. Many files are emitted during the publishing (application files as well as core libraries).
But there is no dotnet.exe included in the published files. Without a dotnet.exe I can't launch the published app!
So I'm confused. Must you have a system wide .net core installed to use self-contained apps, and if so, then you're app certainly isn't self contained.
回答1:
A self-contained app will contain everything needed to run the app.
To run the app, there is no dotnet.exe
but an executable named as your app. So
dotnet publish myapp.csproj -r win-x64
will create a myapp.exe
by default.
For linux runtimes (e.g. -r linux-x64
) the executable will be extension less and is supposed to be run as ./myapp
.
You only need to install .NET Core components if you want to host a self-contained ASP.NET Core application from IIS, since you will need an IIS module to bootstrap the application. You can use this approach though to run newer or preview versions of the .NET Core runtime that you don't want to install globally.
回答2:
Figured this out by using "file" to look at files. Turns out that when you publish app "Foo" for linux, you end up with a file named Foo which is actually an executable the launches your whole app (ie and any libraries it needs, etc).
In other words, there is no "dotnet" command included or needed. Effectively, Foo takes the place of dotnet executable.
来源:https://stackoverflow.com/questions/55579827/do-you-have-to-have-net-core-installed-on-a-system-before-using-self-contained