升级.net6后本地启动成功,但是docker pod中启动成功后又立马失败了,抛出的错误是
{
"ClassName":"System.IO.DirectoryNotFoundException",
"Message":"Manage/wwwroot/",
"Data":null,
"InnerException":null,
"HelpURL":null,
"StackTraceString":" at Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root, ExclusionFilters filters)\n at Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root)\n at Microsoft.AspNetCore.Hosting.StaticWebAssets.StaticWebAssetsLoader.<>c.<UseStaticWebAssetsCore>b__1_0(String contentRoot)\n at Microsoft.AspNetCore.StaticWebAssets.ManifestStaticWebAssetFileProvider..ctor(StaticWebAssetManifest manifest, Func`2 fileProviderFactory)\n at Microsoft.AspNetCore.Hosting.StaticWebAssets.StaticWebAssetsLoader.UseStaticWebAssetsCore(IWebHostEnvironment environment, Stream manifest)\n at Microsoft.AspNetCore.Hosting.StaticWebAssets.StaticWebAssetsLoader.UseStaticWebAssets(IWebHostEnvironment environment, IConfiguration configuration)\n at Microsoft.AspNetCore.WebHost.<>c.<ConfigureWebDefaults>b__9_0(WebHostBuilderContext ctx, IConfigurationBuilder cb)\n at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass9_0.<ConfigureAppConfiguration>b__0(HostBuilderContext context, IConfigurationBuilder builder)\n at Microsoft.Extensions.Hosting.HostBuilder.BuildAppConfiguration()\n at Microsoft.Extensions.Hosting.HostBuilder.Build()\n at Manage.Program.BuildWebHost(String[] args) in Manage/Program.cs:line 133\n at Manage.Program.Main(String[] args) in Manage/Program.cs:line 46",
"RemoteStackTraceString":null,
"RemoteStackIndex":0,
"ExceptionMethod":null,
"HResult":-2147024893,
"Source":"Microsoft.Extensions.FileProviders.Physical",
"WatsonBuckets":null
}
建议进容器看一下对应的路径是否存在
docker run -it image-name /bin/bash
ls Manage/wwwroot/
您好,没有这个路径,是代码问题吗
@劣人的小板凳: 可能是 dotnet publish
时没有复制这个文件夹
@dudu: 多谢了,我试试
@dudu: 构建后的image里包含wwwroot文件,还是报这个错误,请问还有其他原因会导致么
@劣人的小板凳:
@dudu:
这是对应的部分代码和wwwroot的路径~
@劣人的小板凳: 从截图看,wwwroot 正确的路径是 wwwroot/
,不是 Manage/wwwroot/
@劣人的小板凳: 应该是 Host.CreateDefaultBuilder(args)
之前的代码引起的,那些用不到,可以删除
@劣人的小板凳: 就是 IConfiguration configuration = builder.Build()
引起的
@dudu: 文件 配置加载咋会跑到manage/wwwroot里去了,我排查下,谢谢
@劣人的小板凳: 应该是 SetBasePath
引起的, 这个配置根本没用到
@dudu: 去除了以后报错存在,暂时看源码还没看懂报错的原因,最终报错的地方我觉得
应该是初始化FileProvider内容路径报错了