Search code examples
c#.net-coreresx

Resource file is returning path to file instead of file content


There is a resource file .resx and xml files added to it. When accessing from the code, for example, var stringRequest = Resource.GetResponseWithFilter;, it returns the contents of the XML template. Rather, it returns, but not always. When debugging, everything is ok. When publishing by the Visual Studio, everything is ok too. When publishing with the dotnet publish command on TeamCity, it is going to fine, but the returned string is not what I'm waiting for. The resource file has a description of each file:

<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>

And the assembly with TeamCity returns the value of the tag instead of the file content. I tried to set Build Action Embedded resource in xml files - it did not help. All files have the Copy always option set.


Solution

  • It is a bug which fixed in DotNet Core SDK 3.0.

    GenerateResource task does not support non-string resources on .NET core: https://github.com/microsoft/msbuild/issues/2221

    Pull-request with the fix: https://github.com/dotnet/corefx/pull/36906