.net - 使用 .NET Core 3.1 构建需要更多时间和内存(.NET Core 主机和 Visual Studio 代码)
问题描述
我在 Visual Studio Code 编辑器中使用 .NET Core 3.1.2。
在我执行dotnet publish
or之后dotnet 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占用了更多内存。
解决方案
持久性项目具有所有迁移文件。
我注意到该文件夹有 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.
构建问题已解决。
推荐阅读
- java - Android Studio:无法解析导入 (android.support.*)
- facebook - Facebook 的 Unity 插件可以用于发布到产品页面吗?
- r - R Shiny:如何通过服务器中的条件隐藏 tabPanel
- ios - 从另一个值创建新字典
- java - 检查类型后将父对象作为子对象传递
- swift - 禁用 UIWebView 和/或 WKWebView 中样式表的加载
- android - 升级依赖项后无法解析 ActivityTestRule。无法导入 ActivityTestRule
- react-native - 如何配置 Expo 以允许全局模块导入?
- javascript - 异步函数内部的一些错误无法正常工作
- ios - 如何修改 MVVM Cross 中的绑定值