ttmind

Main Navigation

ttmind
  • jim-jams
  • Tech
  • Positive
Login

Login

Facebook Google

OR

Remember me Forgot password?

Don't have account? Signup here.

Sort by Categorys

.Net

PHP

Java

JavaScript

Database

Server

Client Side

Tools

Artificial Intelligence

Cloud

Hybrid Development

Event

Smart City

Education

Security

Scrum

Digital Marketing

APP Development

Business

Internet

Simulation

Art

Network

Microservices

Architecture

Technology

Leadership

    Top Articles

  • How Does Social Media Bring People Together?
    TTMind Author
  • How to read appSettings JSON from Class Library in ASP.NET Core
    Anil Shrestha
  • Printing Support In Asp.Net Core
    TTMind Author
  • HOW TO EXTRACT TEXT FROM IMAGE USING JAVASCRIPT (OCR with Tesseract.js)?
    Prakash Pokhrel
  • Images Upload REST API using ASP.NET Core
    Prakash Pokhrel
  • Related Topic

  • How to read appSettings JSON from Class Library in ASP.NET Core
  • Printing Support In Asp.Net Core
  • Images Upload REST API using ASP.NET Core
  • How to use IActionFilter, IAsyncActionFilter in ASP.NET Core MVC?
  • ASP.NET CORE - Blazor CRUD operation using ADO.NET
  • Tech
  • About Us
  • Contact Us
  • TechHelp
  • PositiveHelp
  • Jim-Jams Help
  • Terms & Conditions

© Copyright ttmind.com

Main Content

How to reduce the size of published files of ASP.NET Core project libraries

.Net .Net Core about 6 years ago || 1/27/2020 || 6.2 K View

  • Hide

As we know ASP.NET Core project needs to published to run in production and we have different types of publishing models, but with the Self-Contained Deployment model, we can reduce the size of libraries with .NET core 3.0 SDK. Many times our project do not need all the things that come with default publishing, so with "PublishTrimmed" options, we can reduce size which just removes unused assemblies in our project.

This can be done either with our Project property or with the setup of the publishing profile.
The option for the project property is like,

<PropertyGroup>
  <PublishTrimmed>true</PublishTrimmed>
</PropertyGroup>

Note:- After changing this setting our project need clean build to get the effect of these type of settings.

Similar to this there are some other properties, which helps for some great works the list is like,

<PropertyGroup>
  <!--disable Quick JIT is enabled and creates fully optimized code -->
  <TieredCompilationQuickJit>false</TieredCompilationQuickJit>
  <!--disable TC completely, use this MSBuild property-->
  <TieredCompilation>false</TieredCompilation>
  <!--Ready To Run-->
  <PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>

Max of the above can be done with publishing wizard too in Visual Studio 2019, The wizard options are like, 

 

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <PublishProvider>FileSystem</PublishProvider>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <PublishSingleFile>True</PublishSingleFile>
    <PublishTrimmed>True</PublishTrimmed>
    <PublishReadyToRun>True</PublishReadyToRun>
    <ProjectGuid>edc08c5c-79ed-45cc-a148-bad46d756508</ProjectGuid>
    <SelfContained>true</SelfContained>
    <publishUrl>D:\BlazorDemo\TrimingApp\PblishFiles</publishUrl>
    <DeleteExistingFiles>True</DeleteExistingFiles>
  </PropertyGroup>
</Project>

and the options looks like the image shown bellow,


 Note:- These options are avilable for Self-Contained Deployment model only

Hope this helps someone who do want some tunning in the productions. 

  • 0
  • 0
  • 0
    • Facebook
    • Twitter
    • Google +
    • LinkedIn

About author

Alok Pandey

Alok Pandey

Love to share what I know.

Reset Your Password
Enter your email address that you used to register. We'll send you an email with your username and a link to reset your password.

Quick Survey