Below are instructions on how to change a Framework-Dependent .NET Core application to a Self-Contained one (i.e. where all the assemblies are included) for Visual Studio 2022.
1) Start Visual Studio 2022.
2) Click ‘Create a new project’.
3) In ‘Create a new project' window, select ASP.NET Core Web App or search it manually, then click on ‘Next’ button.
4) In the next window, type a project name and click ‘Next’.
5) In the next window, choose Framework version and Authentication type. After that, click ‘Create’ button.
6) Open the 'Publish' settings in your project by right clicking on it in the Solution Explorer window and then selecting it.
7) Choose Import Profile and click the ‘Next’ button.
8) Select the publish settings file and click ‘Finish’.
PS: you can easily download publish settings file from control panel like below screenshot.
9) Click ‘Show all settings’, validate the connection with our web deploy server and do not click 'save' button.
10) Then click 'Next' or 'Settings' button to update the 'Deployment Mode' to 'Self-Contained' and 'Target Runtime' to 'win-x86'.
Now, you can deploy your solution to the platform of your choice without the need for certain assemblies to be installed on the server to support a particular .NET Core version.
Note: A Self-Contained ASP.NET Core application does require more memory to run because it is loading all the assemblies required by the version. You can reduce the memory usage by changing thegarbage collection mode from server to workstation. Just add the <ServerGarbageCollection> XML markup to the ASPNETCore.csproj file and set it to "false".