错误 MSB3103:无效的 Resx 文件。指定的模块无法找到
error MSB3103: Invalid Resx file. The specified module could not be found
我正在尝试使用 Jenkins 构建 C# 项目并在 docker 中构建。ps1 第 FIRST 次。
详细错误:
C:\myproject\Properties\Resources.resx : error MSB3103: Invalid Resx
file. Type in the data at line 123, position 5, cannot be loaded
because it threw the following exception during construction: The
specified module could not be found
[C:\myproject\myproject.Config.csproj]
请问这是为什么?有什么原因吗?
更新
这是resources.resx
121 : <data name="config_icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
122 : <value>..\Resources\config_icon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
123 : </data>
这是Config.csproj
123 : <Reference Include="CommonServiceLocator, Version=2.0.4.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
124 :<HintPath>..\packages\CommonServiceLocator.2.0.4\lib\net46\CommonServiceLocator.dll</HintPath>
125 : </Reference>
我不确定这行 no in error message 是否真的指向错误。
在 .resx 文件的属性 Windows(Ctrl+W, P) 中将持久性 属性 更改为:“嵌入在 .resx 文件中”以解决问题。
如果您使用 docker 图像在 Linux 系统中构建您的项目,所有资源名称必须小写
如果你也有这个问题,这可能对你有用。我花了一个星期:(
这个错误是因为服务器内核,内核无法识别那种格式。需要使用另一个 window.
这是参考 link => dotnet build fails
更新
这是我针对此问题的最新 docker 文件,工作正常。看看它,如果你想参考。
它不仅需要安装 MSBuild 工具,还需要安装 Management Build 工具。
#Base Image
FROM mcr.microsoft.com/windows:1903
#Copy Needed Folder
ADD ./setup c:/jenkins
ADD ./jenkinsdata c:/jenkinsdata
#Jenkins
RUN ["msiexec.exe", "/i", "C:\jenkins\jenkins.msi", "/qn"]
#Java
RUN powershell start-process -filepath C:\jenkins\jre-8u251-windows-i586.exe -passthru -wait -argumentlist "/s,INSTALLDIR=c:\Java\jre1.8.0_91,/L,install64.log"
RUN set JAVA_HOME=""c:\Java\jre1.8.0_91\"
RUN set PATH=%PATH%,%JAVA_HOME%\bin
# Install Chocolatey
RUN @powershell -NoProfile -ExecutionPolicy Bypass -Command "$env:ChocolateyUseWindowsCompression='false'; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
RUN powershell choco feature enable -n=allowGlobalConfirmation
# Install Git
RUN powershell choco install git --allow-empty-checksums -y
# Install DotNet 4.6.1
RUN powershell choco install netfx-4.6.1-devpack --allow-empty-checksums -y
# Install MsBuild
RUN powershell choco install visualstudio2017buildtools --allow-empty-checksums -y
# Install ManagementBuildTools
RUN powershell choco install visualstudio2017-workload-manageddesktopbuildtools --allow-empty-checksums -y
# Delete files
RUN Powershell.exe -Command remove-item c:/jenkins –Recurse
我正在尝试使用 Jenkins 构建 C# 项目并在 docker 中构建。ps1 第 FIRST 次。
详细错误:
C:\myproject\Properties\Resources.resx : error MSB3103: Invalid Resx file. Type in the data at line 123, position 5, cannot be loaded because it threw the following exception during construction: The specified module could not be found [C:\myproject\myproject.Config.csproj]
请问这是为什么?有什么原因吗?
更新
这是resources.resx
121 : <data name="config_icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
122 : <value>..\Resources\config_icon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
123 : </data>
这是Config.csproj
123 : <Reference Include="CommonServiceLocator, Version=2.0.4.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
124 :<HintPath>..\packages\CommonServiceLocator.2.0.4\lib\net46\CommonServiceLocator.dll</HintPath>
125 : </Reference>
我不确定这行 no in error message 是否真的指向错误。
在 .resx 文件的属性 Windows(Ctrl+W, P) 中将持久性 属性 更改为:“嵌入在 .resx 文件中”以解决问题。
如果您使用 docker 图像在 Linux 系统中构建您的项目,所有资源名称必须小写
如果你也有这个问题,这可能对你有用。我花了一个星期:(
这个错误是因为服务器内核,内核无法识别那种格式。需要使用另一个 window.
这是参考 link => dotnet build fails
更新
这是我针对此问题的最新 docker 文件,工作正常。看看它,如果你想参考。
它不仅需要安装 MSBuild 工具,还需要安装 Management Build 工具。
#Base Image
FROM mcr.microsoft.com/windows:1903
#Copy Needed Folder
ADD ./setup c:/jenkins
ADD ./jenkinsdata c:/jenkinsdata
#Jenkins
RUN ["msiexec.exe", "/i", "C:\jenkins\jenkins.msi", "/qn"]
#Java
RUN powershell start-process -filepath C:\jenkins\jre-8u251-windows-i586.exe -passthru -wait -argumentlist "/s,INSTALLDIR=c:\Java\jre1.8.0_91,/L,install64.log"
RUN set JAVA_HOME=""c:\Java\jre1.8.0_91\"
RUN set PATH=%PATH%,%JAVA_HOME%\bin
# Install Chocolatey
RUN @powershell -NoProfile -ExecutionPolicy Bypass -Command "$env:ChocolateyUseWindowsCompression='false'; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
RUN powershell choco feature enable -n=allowGlobalConfirmation
# Install Git
RUN powershell choco install git --allow-empty-checksums -y
# Install DotNet 4.6.1
RUN powershell choco install netfx-4.6.1-devpack --allow-empty-checksums -y
# Install MsBuild
RUN powershell choco install visualstudio2017buildtools --allow-empty-checksums -y
# Install ManagementBuildTools
RUN powershell choco install visualstudio2017-workload-manageddesktopbuildtools --allow-empty-checksums -y
# Delete files
RUN Powershell.exe -Command remove-item c:/jenkins –Recurse