繁体   English   中英

使用 .NET Core 3.1 构建需要更多时间和 memory(.NET Core 主机和 Visual Studio 代码)

[英]Build time taking more time and memory (.NET Core Host and Visual Studio Code) using .NET Core 3.1

我在 Visual Studio Code 编辑器中使用 .NET Core 3.1.2。

在我执行dotnet publishdotnet build之后。

构建应用程序需要更多时间。

有时构建会在一分钟内完成。 大多数情况下,完成构建过程需要很长时间。

以下是我正在使用的架构:

文件项目.WebAPI

 <ItemGroup>
    <ProjectReference Include="..\Project.Persistence\Project.Persistence.csproj" />
    <ProjectReference Include="..\Project.Application\Project.Application.csproj" />
  </ItemGroup>

文件项目.应用程序

 <ItemGroup>
    <ProjectReference Include="..\Project.Domain\Project.Domain.csproj" />
    <ProjectReference Include="..\Project.Persistence\Project.Persistence.csproj" />
    <ProjectReference Include="..\Project.Infrastructure\Project.Infrastructure.csproj" />
  </ItemGroup>

文件项目.域

没有其他图书馆提到这一点。

文件项目.持久性

    <ProjectReference Include="..\Project.Domain\Project.Domain.csproj" />
  </ItemGroup>

我已经检查了构建时间需要更多的地方。

Project.Domain库中,构建需要更多时间(几乎 10 分钟)

Task Scheduler中, .NET Core Host占用了更多的 memory。

持久性项目具有所有迁移文件。

我注意到该文件夹有 90 多个迁移文件。

在我使用以下步骤删除所有文件后,

Step 1: Delete all the migration scripts in the Migrations folder.

Step 2: In the package manager console: run

        PM> Add-Migration InitialCreate

Step 3: Delete the code for both the Up() and Down() methods. Before you do this, keep those methods saved elsewhere as we will need them again in step 5.

Step 4: Run:

        PM> Update-Database

It'll insert a new record into __EFMigrationsHistory table.

Step 5: After that, fill the above migration scripts (i.e., ..._InitialCreate) Up() and Down() method from the content kept in a safe place from Step 3.

构建问题已解决。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM