MSBuild.EntityFrameworkCore.RemoveDesignerCompilation 0.1.0-alpha1

This is a prerelease version of MSBuild.EntityFrameworkCore.RemoveDesignerCompilation.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package MSBuild.EntityFrameworkCore.RemoveDesignerCompilation --version 0.1.0-alpha1
NuGet\Install-Package MSBuild.EntityFrameworkCore.RemoveDesignerCompilation -Version 0.1.0-alpha1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MSBuild.EntityFrameworkCore.RemoveDesignerCompilation" Version="0.1.0-alpha1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MSBuild.EntityFrameworkCore.RemoveDesignerCompilation --version 0.1.0-alpha1
#r "nuget: MSBuild.EntityFrameworkCore.RemoveDesignerCompilation, 0.1.0-alpha1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MSBuild.EntityFrameworkCore.RemoveDesignerCompilation as a Cake Addin
#addin nuget:?package=MSBuild.EntityFrameworkCore.RemoveDesignerCompilation&version=0.1.0-alpha1&prerelease

// Install MSBuild.EntityFrameworkCore.RemoveDesignerCompilation as a Cake Tool
#tool nuget:?package=MSBuild.EntityFrameworkCore.RemoveDesignerCompilation&version=0.1.0-alpha1&prerelease

MSBuild.EntityFrameworkCore.RemoveDesignerCompilation

This MSBuild task is designed to remove the compilation of *.Designer.cs files of Entity Framework Core migrations, except for the last N files. It is a simple way to keep your project clean and minimize build times.

To achieve this, the task needs to move the [Migration] and [DBContext] properties from the Designer file to the main file. This is done by using regular expressions, so it is not guaranteed to work in all cases. If you find a case where it does not work, please open an issue and I will try to fix it.

It also needs to add the namespace for your DBContext, so be sure to set that if it's not the same namespace as your project's root namespace.

Getting Started

To start using this package, simply add it as a NuGet package to your project.

Prerequisites

  • .NET Core SDK 3.1 or higher
  • Entity Framework Core 3.1 or higher

Installation

  1. Add the NuGet package to your project:
dotnet add package MSBuild.EntityFrameworkCore.RemoveDesignerCompilation
  1. In your project file, add the following import statement:
<Project Sdk="Microsoft.NET.Sdk">
    ...
    <Import Project="$(MSBuildThisFileDirectory)\MSBuild.EntityFrameworkCore.RemoveDesignerCompilation.targets" />
    ...
</Project>

Configuration

You can customize the behavior of this task by setting the following properties in your project file:

<PropertyGroup>
    <RDC_MigrationFilesPath>$(ProjectDir)\Migrations</RDC_MigrationFilesPath>
    <RDC_DBContextNamespace>$(RootNamespace)</RDC_DBContextNamespace>
    <RDC_DesignerFileCountToKeep>2</RDC_DesignerFileCountToKeep>
</PropertyGroup>
  • RDC_MigrationFilesPath: The path where your Entity Framework Core migration files are located. Default is $(ProjectDir)\Migrations.
  • RDC_DBContextNamespace: The namespace used for your DbContext. Default is the project's root namespace.
  • RDC_DesignerFileCountToKeep: The number of most recent *.Designer.cs files to keep compiling. Default is 2.

Usage

Once you have configured the properties, simply build your project as usual. The MSBuild task will automatically remove the compilation of older *.Designer.cs files in your migration folder, keeping only the last N files as specified in the RDC_DesignerFileCountToKeep property.

License

This project is licensed under the MIT License - see the LICENSE file for details.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.0-alpha6 5,654 5/9/2023
0.1.0-alpha5 100 5/8/2023
0.1.0-alpha4 70 5/8/2023
0.1.0-alpha3 75 5/8/2023
0.1.0-alpha2 69 5/8/2023
0.1.0-alpha1 81 5/8/2023
0.1.0-alpha 76 5/8/2023