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

     正常可以生成迁移文件

     

  • 相关阅读:
    超越自我的事
    ENVI/SARscape软件概述及安装
    《万万没想到:用理工科思维理解世界》读书简记
    Ruby on Rails 搭建环境 (ubuntu)
    拓荒者
    Rails 画类图的几个方法
    ERROR: Error installing mysql2: ERROR: Failed to build gem native extension [@Ubuntu 15.04]
    无题20150105
    关于Unity中Camera的Aspect
    Esfog_UnityShader教程_逐帧动画
  • 原文地址:https://www.cnblogs.com/Martincheng/p/10082670.html
Copyright © 2011-2022 走看看