错误 MSB3103:Resx 文件无效。找不到指定的模块

问题描述 投票:0回答:4

我正在尝试使用 Jenkins 和 build.ps1 在 docker 中构建 c# 项目FIRST 次。

详细错误:

C:\myproject\Properties\Resources.resx:错误 MSB3103:无效的 Resx 文件。在第123行第5位输入数据,无法加载 因为它在构建过程中引发了以下异常: 找不到指定的模块 [C:\myproject\myproject.Config.csproj]

我可以知道为什么会这样吗?有什么理由吗?

更新

这是资源.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 是否真的指出了错误。

c# docker jenkins build msbuild
4个回答
0
投票

在 .resx 文件中的属性窗口(Ctrl+W,P)中将持久性属性更改为:“嵌入在 .resx 文件中”以解决问题。

如果您在Linux系统中使用docker镜像构建项目,所有资源名称必须为小写相关答案


0
投票

如果您也遇到这个问题,这可能对您有用。我花了一周时间:(

这个错误是由于服务器核心造成的,核心无法识别这种格式。需要使用另一个窗口。

这里是参考链接 => dotnet 构建失败

更新

这是我针对此问题的最新 docker 文件,工作正常。如果您愿意的话,请看一下并参考。

不仅需要安装MSBuild工具,还需要安装管理构建工具

#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  

0
投票

我遇到了类似的问题,就我而言,路径名称与文件系统不完全一样(区分大小写)。在 Linux/ubuntu/docker 上构建时,dotnet 资源嵌入器无法在本地文件系统中找到精确匹配。在每个路径(文件夹和文件名)上使用完全相同的情况解决了“文件未找到错误”。显然,在 Linux 上运行时,编译器能够将 '' 更改为 '/'。


0
投票

我遇到了同样的问题,我使用 Azure DevOps 构建了一个 dotnet 项目。

问题: 管道已使用 ubuntu 最新代理。当我使用

dotnet build Release
时,这导致了问题:

**/Properties/Resources.resx(0,0): Error MSB3103: Invalid Resx file. System.IO.DirectoryNotFoundException: Could not find a part of the path '/home/vsts/work/1/s/**/resources/template.html'. at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter) at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Encoding encoding, Int32 bufferSize) at System.IO.StreamReader..ctor(String path, Encoding encoding) at Microsoft.Build.Tasks.ResourceHandling.MSBuildResXReader.AddLinkedResource(String resxFilename, Boolean pathsRelativeToBasePath, List`1 resources, String name, String value) at Microsoft.Build.Tasks.ResourceHandling.MSBuildResXReader.ParseData(String resxFilename, Boolean pathsRelativeToBasePath, List`1 resources, Dictionary`2 aliases, XElement elem) at Microsoft.Build.Tasks.ResourceHandling.MSBuildResXReader.ReadResources(Stream s, String filename, Boolean pathsRelativeToBasePath)

原因:与应用程序与操作系统的兼容性有关。

解决方案:问题的解决方法是,将虚拟机代理从

ubuntu-latest
更改为
windows-latest

© www.soinside.com 2019 - 2024. All rights reserved.