人如果没有梦想那和咸鱼有什么区别,即使是做咸鱼也要做最咸的那一条

—— Wy

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,冒得问题了


评论

用户默认头像
发表我的评论
取消评论
看不清,点击刷新验证码
  1. 用户默认头像
    写得真好,正好是我想要的
    杜海明 2019年10月25日 22:24:00 回复