mysql读写分离 abp_AbpCore 执行迁移文件生成数据库报错 Could not find root folder of the web project!...

背景介绍

下载开源52abp项目(https://github.com/52ABP/LTMCompanyNameFree.YoyoCmsTemplate)进行修改项目名称

3ca8ce0bbc9e271a01f641df99131d64.png

准备update-database 指令生成数据库,报错如下:

System.Exception: Could not find root folder of the web project!

at YY.Frame.AbpCore.Web.WebContentDirectoryFinder.CalculateContentRootFolder() in G:\ABP Core\Github\LTMCompanyNameFree.YoyoCmsTemplate-master(abp4.0.2)\src\aspnet-core\src\YY.Frame.AbpCore.Core\Web\WebContentFolderHelper.cs:line 46

at YY.Frame.AbpCore.EntityFrameworkCore.YoyoCmsTemplateDbContextFactory.CreateDbContext(String[] args) in G:\ABP Core\Github\LTMCompanyNameFree.YoyoCmsTemplate-master(abp4.0.2)\src\aspnet-core\src\YY.Frame.AbpCore.EntityFrameworkCore\EntityFrameworkCore\YoyoCmsTemplateDbContextFactory.cs:line 15

at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(Func`1 factory)

at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(String contextType)

at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String name, String outputDir, String contextType)

at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType)

at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.b__0()

at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)

Could not find root folder of the web project!

仔细看报错信息

0731cdb5fc9504b123270ab147a36cf6.png

调用var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder());这地方抛出的

CalculateContentRootFolder

public static string CalculateContentRootFolder()

{

var coreAssemblyDirectoryPath = Path.GetDirectoryName(typeof(YoyoCmsTemplateCoreModule).GetAssembly().Location);

if (coreAssemblyDirectoryPath == null)

{

throw new Exception("Could not find location of YY.Frame.AbpCore.Core assembly!");

}

var directoryInfo = new DirectoryInfo(coreAssemblyDirectoryPath);

while (!DirectoryContains(directoryInfo.FullName, "YY.Frame.AbpCore.sln"))

{

if (directoryInfo.Parent == null)

{

throw new Exception("Could not find content root folder!");

}

directoryInfo = directoryInfo.Parent;

}

var webMvcFolder = Path.Combine(directoryInfo.FullName, "src", "YY.Frame.AbpCore.Web.Mvc");

if (Directory.Exists(webMvcFolder))

{

return webMvcFolder;

}

var webHostFolder = Path.Combine(directoryInfo.FullName, "src", "YY.Frame.AbpCore.Web.Host");

if (Directory.Exists(webHostFolder))

{

return webHostFolder;

}

throw new Exception("Could not find root folder of the web project!");

}

看完上面代码,把目录抛出来看看

b2f49e23d41c360d898f17d19e1947c2.png

不难发现dll都生成在netcoreapp2.1 目录下,并没有在src文件夹

c039cb8483320d814ff134745887114c.png

解决方法把CalculateContentRootFolder方法中src目录去掉

public static stringCalculateContentRootFolder()

{var coreAssemblyDirectoryPath = Path.GetDirectoryName(typeof(YoyoCmsTemplateCoreModule).GetAssembly().Location);if (coreAssemblyDirectoryPath == null)

{throw new Exception("Could not find location of YY.Frame.AbpCore.Core assembly!");

}var directoryInfo = newDirectoryInfo(coreAssemblyDirectoryPath);//throw new Exception(directoryInfo.FullName);

while (!DirectoryContains(directoryInfo.FullName, "YY.Frame.AbpCore.sln"))

{if (directoryInfo.Parent == null)

{throw new Exception("Could not find content root folder!");

}

directoryInfo=directoryInfo.Parent;

}var webMvcFolder = Path.Combine(directoryInfo.FullName, "", "YY.Frame.AbpCore.Web.Mvc");if(Directory.Exists(webMvcFolder))

{returnwebMvcFolder;

}var webHostFolder = Path.Combine(directoryInfo.FullName, "", "YY.Frame.AbpCore.Web.Host");if(Directory.Exists(webHostFolder))

{returnwebHostFolder;

}throw new Exception("Could not find root folder of the web project!");

}

正常可以生成迁移文件

dddea05d5777e09dd8ef164597d09a28.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值