Core-to-Core: Converting a Framework-Dependent App to Self-Contained in Visual Studio Print

  • 4

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.
 
1) Start Visual Studio.

2) Open a new project by selecting File -> New -> Project (CTRL-SHIFT-N)

3) In the New Project window, choose .NET Framework 4.6 or higher and a programming language, select Web, then ASP.NET Core Application (.NET Core), give your project a name, and click on OK.

4) In the next window, select .NET Core in the left drop-down box, the ASP.NET Core version in the right drop-down box, highlight Web Application, and click on the OK button.

5) Open the .csproj file in your project by right-clicking on it in the Solution Explorer window and then selecting it.

6) Add the following XML markup to the file in the PropertyGroup section to specify the platform you want to deploy your application to.

 A complete list of Runtime IDs can be found here.
<RuntimeIdentifier>win8-x64</RuntimeIdentifier>
7) Go to Tools -> NuGet Package Manager -> Package Manager Console to open the console window at the bottom.
 
8) In the console window, type in "dotnet restore" and hit enter.  Wait for it to finish.
 
9) Rebuild your project (CTRL-SHIFT-B)
 
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 the garbage 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>

Was this answer helpful?

« Back