|
|
@@ -52,33 +52,50 @@ enough. Here is a list of recommended VPS provider. |
|
|
|
|
|
|
|
> [!NOTE] |
|
|
|
> This section only covers the very basics of .NET Core deployment. |
|
|
|
> To learn more about deployment, visit [.NET Core application deployment] |
|
|
|
> by Microsoft. |
|
|
|
> To learn more about .NET Core deployment, |
|
|
|
> visit [.NET Core application deployment] by Microsoft. |
|
|
|
|
|
|
|
By default, .NET Core compiles all projects as a DLL file, so that any |
|
|
|
.NET Core runtime can execute the application. |
|
|
|
When redistributing the application - whether for deployment on a |
|
|
|
remote machine or for sharing with another user - you may want to |
|
|
|
publish the application; in other words, to create a |
|
|
|
self-contained package without installing the dependencies |
|
|
|
and the runtime on the target machine. |
|
|
|
|
|
|
|
You may execute the application via `dotnet myprogram.dll` assuming you |
|
|
|
have the dotnet CLI installed. |
|
|
|
### Framework-dependent Deployment |
|
|
|
|
|
|
|
When redistributing the application, you may want to publish the |
|
|
|
application, or in other words, create a self-contained package |
|
|
|
for use on another machine without installing the dependencies first. |
|
|
|
|
|
|
|
This can be achieved by using the dotnet CLI too on the development |
|
|
|
machine: |
|
|
|
To deploy a framework-dependent package (i.e. files to be used on a |
|
|
|
remote machine with the `dotnet` command), simply publish |
|
|
|
the package with: |
|
|
|
|
|
|
|
* `dotnet publish -c Release` |
|
|
|
|
|
|
|
Additionally, you may want to target a specific platform when |
|
|
|
publishing the application so you may use the application without |
|
|
|
having to install the Core runtime on the target machine. To do this, |
|
|
|
you may specify an [Runtime ID] upon build/publish with the `-r` |
|
|
|
option. |
|
|
|
|
|
|
|
For example, when targeting a Windows 10 machine, you may want to use |
|
|
|
the following to create the application in Windows executable |
|
|
|
format (.exe): |
|
|
|
This will create a package with the **least dependencies** |
|
|
|
included with the application; however, the remote machine |
|
|
|
must have `dotnet` runtime installed before the remote could run the |
|
|
|
program. |
|
|
|
|
|
|
|
> [!TIP] |
|
|
|
> Do not know how to run a .NET Core application with |
|
|
|
> the `dotnet` runtime? Navigate to the folder of the program and |
|
|
|
> enter `dotnet program.dll` where `program.dll` is your compiled |
|
|
|
> binaries. |
|
|
|
|
|
|
|
### Self-contained Deployment |
|
|
|
|
|
|
|
To deploy a self-contained package (i.e. files to be used on a remote |
|
|
|
machine without the `dotnet` runtime), publish with a specific |
|
|
|
[Runtime ID] with the `-r` switch. |
|
|
|
|
|
|
|
This will create a package with dependencies compiled for the target |
|
|
|
platform, meaning that all the required dependencies will be included |
|
|
|
with the program. This will result in **larger package size**; |
|
|
|
however, not only is the portabilitiy greatly increased, but also the |
|
|
|
it will include a copy of the executable that can be run |
|
|
|
natively on the target runtime. |
|
|
|
|
|
|
|
For example, the following command will create a Windows |
|
|
|
executable (`.exe`) that is ready to be executed on any |
|
|
|
Windows 10 x64 based machine: |
|
|
|
|
|
|
|
* `dotnet publish -c Release -r win10-x64` |
|
|
|
|
|
|
|