zoukankan      html  css  js  c++  java
  • AbpCore 执行迁移文件生成数据库报错 Could not find root folder of the web project!

    背景介绍

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

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

    System.Exception: Could not find root folder of the web project!
       at YY.Frame.AbpCore.Web.WebContentDirectoryFinder.CalculateContentRootFolder() in G:ABP CoreGithubLTMCompanyNameFree.YoyoCmsTemplate-master(abp4.0.2)srcaspnet-coresrcYY.Frame.AbpCore.CoreWebWebContentFolderHelper.cs:line 46
       at YY.Frame.AbpCore.EntityFrameworkCore.YoyoCmsTemplateDbContextFactory.CreateDbContext(String[] args) in G:ABP CoreGithubLTMCompanyNameFree.YoyoCmsTemplate-master(abp4.0.2)srcaspnet-coresrcYY.Frame.AbpCore.EntityFrameworkCoreEntityFrameworkCoreYoyoCmsTemplateDbContextFactory.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.<Execute>b__0()
       at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
    Could not find root folder of the web project!

    仔细看报错信息

      调用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!");
            }

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

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

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

     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);
    
               // 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))
                {
                    return webMvcFolder;
                }
    
                var webHostFolder = Path.Combine(directoryInfo.FullName, "", "YY.Frame.AbpCore.Web.Host");
                if (Directory.Exists(webHostFolder))
                {
                    return webHostFolder;
                }
    
                throw new Exception("Could not find root folder of the web project!");
            }

     正常可以生成迁移文件

     

  • 相关阅读:
    了解NAT及P2P技術
    MS sqlserver數據恢復
    cvs定時備份
    html結合javascript實現的進度條
    在linux下oracle自啟動腳本
    android_activity_研究(一)
    android_onSaveInstanceState_onRestoreInstanceState研究
    android_sdcard读写(三)
    android_activity_研究(二)
    android_sdcard读写(一)
  • 原文地址:https://www.cnblogs.com/Martincheng/p/10082670.html
Copyright © 2011-2022 走看看