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 2017.
1) Start Visual Studio.
2) Open a new project by selecting File -> New -> Project (CTRL-SHIFT-N)
3) In the New Project window, select Web, then ASP.NET Core Application (.NET Core), give your project a name and click on OK.
4) In the next window, select the ASP.NET Core Version, highlight Web Application and click on the OK button.
5) Open the 'Publish' settings in your project by right clicking on it in the Solution Explorer window and then selecting it.
6)Click the 'IIS,FTP,etc' option and click the 'Publish' button.
7) Validate the connection with our web deploy server and do not click 'save' button
8)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".
<PropertyGroup>
<ServerGarbageCollection>false</ServerGarbageCollection>
</PropertyGroup>
Article ID: 1933, Created: November 17, 2017 at 2:06 AM, Modified: September 12, 2018 at 6:31 AM