ABP踩坑記錄一 CalculateContentRootFolder函數的坑

ABP在IIS上發佈時報錯 ,報錯信息:Could not find content root folder!

 

 

報的異常信息來自這個函數,

 

public static string CalculateContentRootFolder()
        {
            var coreAssemblyDirectoryPath = Path.GetDirectoryName(typeof(BlogCoreModule).GetAssembly().Location);
            if (coreAssemblyDirectoryPath == null)
            {
                throw new Exception("Could not find location of CC.Blog.Core assembly!");
            }

            var directoryInfo = new DirectoryInfo(coreAssemblyDirectoryPath);
            if (DirectoryContains(directoryInfo.FullName, "appsettings.json"))
            {
                return directoryInfo.FullName;
            }
            while (!DirectoryContains(directoryInfo.FullName, "CC.Blog.sln"))
            {
                if (directoryInfo.Parent == null)
                {
                    throw new Exception("Could not find content root folder!");
                }

                directoryInfo = directoryInfo.Parent;
            }

            var webMvcFolder = Path.Combine(directoryInfo.FullName, "src", "CC.Blog.Web.Mvc");
            if (Directory.Exists(webMvcFolder))
            {
                return webMvcFolder;
            }

            var webHostFolder = Path.Combine(directoryInfo.FullName, "src", "CC.Blog.Web.Host");
            if (Directory.Exists(webHostFolder))
            {
                return webHostFolder;
            }

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

在裏面加了一個判斷

if (DirectoryContains(directoryInfo.FullName, "appsettings.json"))
            {
                return directoryInfo.FullName;
            }

OK,冒得問題了

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章