Publish .NET applications to folder
One of the ways to deploy an application is to pack all its files to a folder and then share this folder with others. This may be helpful when testing the application or sending it to a dedicated deployment team.
The first thing you need to do is create a run configuration that determines what and how should be published.
Create a configuration for publishing
Open the Run/Debug Configuration dialog in one of the following ways:
Select
from the main menu.With the Navigation bar visible ( ), choose from the run/debug configuration selector.
Press Alt+Shift+F10 and then press 0.
In the Run/Debug Configuration dialog, click Add New Configuration Alt+Insert, choose the Publish to folder configuration type, and specify a name that will help you identify this configuration in the future.
Optionally, adjust the common settings of the configuration and configure before launch tasks.
Select the main project of your application in the Project field and specify its parameters, which are explained in the table below.
Click Apply to save the configuration.
You can set the following parameters of the Publish to Folder configuration:
Target location | Use this field to specify where to deploy application files. |
Configuration | Select a build configuration. |
Target framework | Lets you change the .NET framework version that the project targets. For more information, see Framework targeting overview and Target frameworks in SDK-style projects on Microsoft Docs. |
Deployment mode |
For more information, see Microsoft Learn. .NET application publishing overview. |
Target runtime | If you are not sure where the application is going to be executed, choose Portable. The downside of this option is that the target machine will have to JIT compile your application each time it runs. Otherwise, select a specific runtime identifier (RID) from the list or specify a custom one. For more information, see Microsoft Learn. .NET RID Catalog. |
Enable ReadyToRun compilation | This option may help improve startup performance of the application, but on the other hand, the size of the artifact will grow. For more information, see Microsoft Learn. ReadyToRun Compilation. |
Trim unused assemblies | This option is available for the self-contained deployment mode and lets you trim unused dependencies. For more information, see Microsoft Learn. Trim self-contained deployments and executables. |
Produce single file | Use this option to compile all application files into a single binary file. For more information, see Microsoft Learn. Single-file deployment and executable. |
Delete existing files | Will delete all the existing files in the deployment location before deploying the application. |
When you a ready to publish your application, select the created run configuration on the toolbar and click Run Shift+F10: