IntelliTect / IntelliTect/EssentialCSharp

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

Aperta
#378 1 commento 1 reazione 1 assegnatario Rivendicata da @MarkMichaelis Vedi su GitHub
manuscript
Lingua principale
C#
Stelle
418
Fork
173
Merge medio
3m
PR unite (30g)
3

Descrizione

# 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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.