Below are the steps on how to change a Framework-Dependent .NET Core application to a Self-Contained one for Visual Studio 2017.
-Start Visual Studio.
-Please open a new project by selecting File > New > Project
-In the New Project window, select Web, then ASP.NET Core Application (.NET Core), give your project a name, and click on OK.

-In the next window, select the ASP.NET Core Version and highlight Web Application and click on the OK button.

- Open the 'Publish' settings in your project by right-clicking on it in the Solution Explorer window and then selecting it.

-Please click the 'IIS, FTP, etc' option and click the 'Publish' button.

- Validate the connection with our web deploy server and do not click the 'save' button

Then please 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>