具有文件内容的.Net资源使Docker构建失败 [英] .Net resource with files content make docker build fail

查看:138
本文介绍了具有文件内容的.Net资源使Docker构建失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

"dotnet build"构建没有错误的项目,同时docker build产生以下错误:

"dotnet build" builds a project with no errors, and at the same time docker build gives following error:

/src/Audit.Worker/Example/Resources.resx : error MSB3103: Invalid Resx file. System.IO.DirectoryNotFoundException: Could not find a part of the path '/src/Audit.Worker/Example/data/example.yaml'. [/src/Audit.Worker/Audit.Worker.csproj]

Dockerfile

Dockerfile

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["./Audit.Worker/Audit.Worker.csproj", "Audit.Worker/"]
RUN dotnet restore "Audit.Worker/Audit.Worker.csproj"
COPY . /src/
WORKDIR "/src/Audit.Worker/"
RUN dotnet build "Audit.Worker.csproj" -c Release -o /apps

FROM build AS publish
RUN dotnet publish "Audit.Worker.csproj" -c Release -o /apps

FROM base AS final
WORKDIR /apps
COPY --from=publish /apps .
ENTRYPOINT ["dotnet", "Audit.Worker.dll"]

推荐答案

最终,我弄清了原因.

Visual Studio资源工具(我认为它负责生成.resx文件内容)假设文件路径不区分大小写,并以小写形式生成所有文件路径(即 data \ example.yaml ).同时,用于构建的基础docker映像基于Linux,其中路径区分大小写.

Visual Studio resources tool (I assume it responsible for .resx file content generation) makes an assumption that file paths are case insensitive and generates all file paths in lower case (i.e. data\example.yaml). At the same time base docker image used for the build is based on Linux where paths are case sensitive.

  <data name="Example" type="System.Resources.ResXFileRef, System.Windows.Forms">
    <value>data\example.yaml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
  </data>

底线:尽管可行的解决方案是手动编辑.resx文件(或在需要时使用小写字母),我们决定完全避免使用资源.似乎已经没有适当的支持了.

Bottom line: nevertheless working solution was to manually edit .resx file (or use lowercase where it's needed), we decided to avoid using resources at all. It seems there is no proper support for it anymore.

这篇关于具有文件内容的.Net资源使Docker构建失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆