【问题标题】:Resource file is returning path to file instead of file content资源文件正在返回文件路径而不是文件内容
【发布时间】:2019-08-05 05:52:22
【问题描述】:

添加了资源文件 .resx 和 xml 文件。从代码访问时,例如var stringRequest = Resource.GetResponseWithFilter;,它返回XML 模板的内容。相反,它会返回,但并非总是如此。调试时,一切正常。通过 Visual Studio 发布时,一切正常。在 TeamCity 上使用 dotnet publish 命令发布时,一切正常,但返回的字符串不是我所期待的。 资源文件有每个文件的描述:

<data name = "GetResponseWithFilter" type = "System.Resources.ResXFileRef, System.Windows.Forms">
    <value> XML Requests \ GET \ GetResponseWithFilter.xml; System.String, mscorlib, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089; windows-1251 </value>
  </data>

并且带有 TeamCity 的程序集返回标签的值而不是文件内容。 我试图在 xml 文件中设置 Build Action Embedded resource - 它没有帮助。所有文件都设置了Copy always 选项。

【问题讨论】:

    标签: c# .net-core resx


    【解决方案1】:

    这是 DotNet Core SDK 3.0 中修复的错误。

    GenerateResource 任务不支持 .NET core 上的非字符串资源: https://github.com/microsoft/msbuild/issues/2221

    带有修复的拉取请求: https://github.com/dotnet/corefx/pull/36906

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-27
      • 2019-01-29
      相关资源
      最近更新 更多