Login Register
Code2night
  • Home
  • Guest Posts
  • Blog Archive
  • Tutorial
  • Languages
    • Angular
    • C
    • c#
    • C#
    • HTML/CSS
    • Java
    • JavaScript
    • Node.js
    • Python
    • React
    • Security
    • SQL Server
    • TypeScript
  • Post Blog
  • Tools
    • JSON Beautifier
    • HTML Beautifier
    • XML Beautifier
    • CSS Beautifier
    • JS Beautifier
    • PDF Editor
    • Word Counter
    • Base64 Encode/Decode
    • Diff Checker
    • JSON to CSV
    • Password Generator
  1. Home
  2. Blogpost

App Trim in .NET Core

Date- May 31,2023

4496

app trim dotnet core

In .NET Core, the "App Trim" feature helps reduce the size of the published application by removing unused code and assemblies. It analyzes the application's dependencies and trims out any unused parts, resulting in a smaller deployment package.

To enable App Trim in .NET Core, you need to perform the following steps:

  1. Update your project file: Open your project file (.csproj) and ensure that the PublishTrimmed property is set to true. You can set this property inside a configuration like Debug or Release depending on your needs:
<PropertyGroup>
  <PublishTrimmed>true</PublishTrimmed>
</PropertyGroup>
  1. Publish the application: Use the dotnet publish command to build and publish your application. Specify the desired target framework and configuration. For example:


dotnet publish -c Release -r <runtime-identifier>

Replace <runtime-identifier> with the appropriate runtime identifier for your target platform (e.g., win-x64, linux-x64, osx-x64).

  1. Verify the trimmed output: After publishing, check the output folder for the trimmed application. You should notice a reduction in the size of the published files compared to an untrimmed build.

It's important to note that App Trim works best when your application uses the .NET SDK-style projects (<Project Sdk="Microsoft.NET.Sdk">). Additionally, App Trim requires .NET Core 3.0 or higher.

Keep in mind that while App Trim can significantly reduce the size of the published application, it may also remove some code that is used dynamically at runtime. Therefore, it's recommended to thoroughly test your application after enabling App Trim to ensure that all expected functionality is intact.

You can refer to the official documentation for more details on using App Trim in .NET Core: https://docs.microsoft.com/en-us/dotnet/core/deploying/app-trimming

S
Shubham Batra
Programming author at Code2Night — sharing tutorials on ASP.NET, C#, and more.
View all posts →

Related Articles

Implement Stripe Payment Gateway In ASP.NET Core
Jul 01, 2023
How to upload files to Azure Blob Storage in an ASP.NET Core Web
Feb 27, 2023
How to use Azure Blob Storage in an ASP.NET Core Web API to list, upload, download, and delete files
Feb 26, 2023
Web Api in Asp.net core
Dec 03, 2022

Comments

Contents

More in ASP.NET Core

  • How to Encrypt and Decrypt Password in Asp.Net 25907 views
  • Exception Handling Asp.Net Core 20687 views
  • HTTP Error 500.31 Failed to load ASP NET Core runtime 20164 views
  • How to implement Paypal in Asp.Net Core 19581 views
  • Task Scheduler in Asp.Net core 17473 views
View all ASP.NET Core posts →

Tags

AspNet
C#
programming
AspNet MVC
c programming
AspNet Core
C
software development
tutorial
MVC
memory management
Paypal
coding
coding best practices
data structures
programming tutorial
tutorials
object oriented programming
Slick Slider
StripeNet
Free Download for Youtube Subscribers!

First click on Subscribe Now and then subscribe the channel and come back here.
Then Click on "Verify and Download" button for download link

Subscribe Now | 1760
Download
Support Us....!

Please Subscribe to support us

Thank you for Downloading....!

Please Subscribe to support us

Continue with Downloading
Be a Member
Join Us On Whatsapp Join Us On Facebook
Code2Night

A community platform for sharing programming knowledge, tutorials, and blogs. Learn, write, and grow with developers worldwide.

Panipat, Haryana, India
info@code2night.com
Quick Links
  • Home
  • Blog Archive
  • Tutorials
  • About Us
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Guest Posts
Free Dev Tools
  • JSON Beautifier
  • HTML Beautifier
  • CSS Beautifier
  • JS Beautifier
  • Password Generator
  • QR Code Generator
  • Hash Generator
  • Diff Checker
  • Base64 Encode/Decode
  • Word Counter
By Language
  • Angular
  • C
  • c#
  • C#
  • HTML/CSS
  • Java
  • JavaScript
  • Node.js
  • Python
  • React
  • Security
  • SQL Server
  • TypeScript
© 2026 Code2Night. All Rights Reserved.
Made with for developers  |  Privacy  ·  Terms
Translate Page