由于 EF 代码迁移,Teamcity 构建失败

Teamcity build fails because of EF code migrations

我的 TeamCity 构建失败,因为我的项目中有 2 个 EF 代码迁移配置。

来自构建日志:

[12:39:58]Checking for changes
[12:39:58]Collecting changes in 1 VCS root (1s)
[12:40:00]Clearing temporary directory: C:\TeamCity\buildAgent2\temp\buildTmp
[12:40:00]Publishing internal artifacts
[12:40:00]Checkout directory: C:\TeamCity\buildAgent2\work79b8b30e00ad0
[12:40:00]Updating sources: server side checkout (2s)
[12:40:03]Step 1/8: Gulp (Command Line)
[12:40:03]Step 2/8: Nuget Package Refresh (NuGet Installer) (3s)
[12:40:06]Step 3/8: Compile (MSBuild) (21s)
[12:40:27]Step 4/8: Unit Tests (NUnit) (33s)
[12:41:01]Step 5/8: Transform Files (Powershell) (2s)
[12:41:03]Step 6/8: Deployment Build on XXXXX Live (MSBuild) (25s)
[12:41:29]Step 7/8: Deploy Database (Powershell) (5s)
[12:41:34]Step 8/8: Deploy Portal.Hub (Powershell) (33s)
[12:42:08]Publishing artifacts
[12:42:08][Publishing artifacts] Collecting files to publish:     [C:\TeamCity\buildAgent2\temp\buildTmp\nuget5954880593924726328packages\nuget.xml => .teamcity/nuget]
[12:42:08][Publishing artifacts] Publishing using [WebPublisher]
[12:42:08][Publishing artifacts] Publishing using [ArtifactsCachePublisher]
[12:42:08][Publishing artifacts] Artifacts path 'C:/TeamCity/buildAgent2/temp/buildTmp/nuget5954880593924726328packages/nuget.xml' not found
[12:42:08]Reverting patched assembly versions
[12:42:08][Reverting patched assembly versions] Restoring C:\TeamCity\buildAgent2\work79b8b30e00ad0\src\Portal.Api\Properties\AssemblyInfo.cs
[12:42:08][Reverting patched assembly versions] Restoring C:\TeamCity\buildAgent2\work79b8b30e00ad0\src\Portal.Common\Properties\AssemblyInfo.cs
[12:42:08][Reverting patched assembly versions] Restoring C:\TeamCity\buildAgent2\work79b8b30e00ad0\src\Portal.Data\Properties\AssemblyInfo.cs
[12:42:08][Reverting patched assembly versions] Restoring C:\TeamCity\buildAgent2\work79b8b30e00ad0\src\Portal.Hub\Properties\AssemblyInfo.cs
[12:42:08][Reverting patched assembly versions] Restoring C:\TeamCity\buildAgent2\work79b8b30e00ad0\src\Portal.Manager\Properties\AssemblyInfo.cs
[12:42:08][Reverting patched assembly versions] Restoring C:\TeamCity\buildAgent2\work79b8b30e00ad0\src\Portal.Managers\Properties\AssemblyInfo.cs
[12:42:08][Reverting patched assembly versions] Restoring C:\TeamCity\buildAgent2\work79b8b30e00ad0\src\Portal.SignalR\Properties\AssemblyInfo.cs
[12:42:08][Reverting patched assembly versions] Restoring C:\TeamCity\buildAgent2\work79b8b30e00ad0\src\Portal.Tests\Properties\AssemblyInfo.cs
[12:42:08]Publishing internal artifacts
[12:42:08][Publishing internal artifacts] Sending using WebPublisher
[12:42:08][Publishing internal artifacts] Sending using ArtifactsCachePublisher
[12:42:08]Build failure condition: There was an error reported in one of the build steps.
[12:42:08]Build failure condition cause message: ERROR: More than one migrations configuration type was found in the assembly 'Portal.Data'. Specify the name of the one to use. (show original message)
[12:42:08]Build finished

注意:唯一的红色(失败)是上面的最后两行 "Build Finished"

我没有 运行迁移,我在团队城市或发布配置文件中看不到任何尝试执行此操作的步骤。

我不想将我的配置拆分到单独的项目中,我只是想阻止 TeamCity 尝试 运行 它们。

我的构建步骤是:

1/8 Gulp - 最小化 js 文件

2/8 NuGet 安装程序 - 更新解决方案中的 nuget 引用

3/8 MSBuild - .NET 4.5 x86 编译

4/8 NUnit - 运行 单元测试

5/8 Powershell - 运行 用于为 windows 服务

操作 app.config 文件的脚本

6/8 MSBuild - 使用发布配置文件部署网站

7/8 Powershell - 部署数据库的脚本

8/8 Powershell - 用于部署 windows 服务的脚本

发布配置文件:连接选项卡上的验证连接按钮工作正常,在设置页面上列出了几个数据库,但 none 有连接字符串或 "use this connection string at runtime" 选中。其中一个旁边有一个信息标签 "In order to publish a Code First Model, Code First Migrations should be used"。

对于其他工作正常的项目,我们有几乎相同的构建配置。

谢谢

从日志来看,您似乎正在尝试在步骤 7 - 部署数据库步骤中应用 EF 迁移。

这是抛出配置异常的地方。

如果目标是从 运行 中阻止 TeamCity,那么禁用该步骤即可。

希望对您有所帮助