ASP.NET Core 8.0 MVC项目构建Docker镜像时apphost复制失败及禁用UseAppHost后资源丢失问题求助
ASP.NET Core 8.0 MVC项目构建Docker镜像时apphost复制失败及禁用UseAppHost后资源丢失问题求助
我正在构建一个基于.NET 8.0的ASP.NET Core MVC应用,在构建Docker镜像时遇到了一个错误——系统无法将apphost复制到目标位置,提示它是文件夹而非文件。这个问题只出现在这个MVC项目上,其他项目比如API都没有问题。
Error MSB3024: Could not copy the file "//obj/Release/net8.0/apphost" to the destination file "bin/Release/net8.0/AppInterface", because the destination is a folder instead of a file. To copy the source file into a folder, consider using the DestinationFolder parameter instead of DestinationFiles. [/AppInterface.csproj]
AppInterface是我的程序集名称,我试过多次修改它的名称,还尝试在.csproj里添加以下配置:
<ItemGroup> <AppHostFile Include="obj/Release/net8.0/apphost" /> </ItemGroup> <Target Name="CopyAppHost" AfterTargets="Build"> <Copy SourceFiles="@(AppHostFile)" DestinationFiles="bin/Release/net8.0/apphost.exe" /> </Target>
我试过网上能找到的所有解决方案,但都没能真正解决问题。只有一个方法没报错——在.csproj文件里添加了这一行:
<UseAppHost>false</UseAppHost>
这样Docker镜像能成功创建并推送到Azure容器注册表,但运行时发现视图文件和wwwroot文件夹都找不到了。
有没有人知道该怎么解决这个问题?
备注:内容来源于stack exchange,提问作者Ivan
相关产品推荐
相关产品推荐

