IntelliTect / IntelliTect/EssentialCSharp

Find an alternate location (or delete) Publishing a Stand-Alone Executable - Advanced Block

Offen
#378 1 Kommentar 1 Reaktion 1 zugewiesene Person Beansprucht von @MarkMichaelis Auf GitHub ansehen
manuscript
Vorherrschende Sprache
C#
Sterne
418
Forks
173
Ø Merge
3 Min.
Gemergte PRs (30 T.)
3

Beschreibung

# Advanced Topic
# Publishing a Stand-Alone Executable
It is possible to output a stand-alone executable that can run independently of the dotnet command. To achieve this, run the `dotnet publish` command with the `--runtime` (`-r`) argument that identifies the target platform (operating system) the output will be compatible with. For example, on most Linux platforms you can use `linux-x64` from the same directory as the CSPROJ file is located:
```
dotnet publish --runtime linux-x64
```
Executing this command will create a directory (`./bin/Debug/netcoreapp3.1/linux-x64/publish/`) that includes all the files necessary to run the `HelloWorld` console program without first installing the dotnet runtime. To execute the `HelloWorld` program, simply invoke the executable name, specifying the path if the current directory is not the `publish` directory:
```
./bin/Debug/netcoreapp3.1/linux-x64/publish/HelloWorld
```
(On windows, the executable name will include a .exe extension. but it isn’t necessary to specify this when running the program.)

Be aware that the resulting executable will only run on a linux-x64–compatible platform. You will need to execute the `dotnet publish` command for each platform you are targeting. Common runtime identifiers on other platforms include win-x64 and osx-x64 (for a full list, see http://itl.tc/ridcatalog).

It is also possible to publish a stand-alone executable into a single file (rather than the approximately 200 files needed otherwise). For a single executable, append `-p:PublishSingleFile=true` to the command:
```
dotnet publish --runtime linux-x64 -p:PublishSingleFile=true
```
More information about the -p argument appears in Chapter 10.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.