Issue Description
I have files linked into my Resx file which is getting built into my project. When I change the contents of a text file and then save the resource is not regenerated when I build. However, something like an image file linked into my Resx will trigger resource generation upon changes.
Steps to Reproduce
demo-project.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>bug_demo_resgen</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Drawing.Common" Version="10.0.2" />
<PackageReference Include="System.Resources.Extensions" Version="10.0.2" />
</ItemGroup>
</Project>
TestResource.resx:
<?xml version="1.0" encoding="utf-8"?>
<root>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="MyResourceText" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>MyResourceText.txt;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="TestImage" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>TestImage.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Referenced resources:
To reproduce the error:
- Build the project
- Change the contents of MyResourceText.txt and save, then build the project (NOT rebuild). Notice that the resource is not regenerated
- Change the contents of TestImage.bmp and save, then build the project (NOT rebuild). Notice that the resource IS regenerated
Expected Behavior
My expectation is that changes to any System.Resources.ResXFileRef should cause the resource to be regenerated in the build.
Actual Behavior
Instead, only changes to certain linked file types are causing the resource to be regenerated.
Analysis
I believe this is caused by ResXFile.GetLinkedFile here checking only for the type FileStreamResource. Looking at MSBuildResXReader.GetResourcesFromFile the only way to get a FileStreamResource returned from that is for it NOT to be a String or a Byte[] or a MemoryStream.
Logically, I would like for everything which is a type="System.Resources.ResXFileRef" to be considered for triggering a regeneration of the resource file and not just the things which are NOT String/Byte[]/MemoryStream. Is the current implemented some kind of build optimization or speedup? If so, are there any switches I could use to turn it off?
Versions & Configurations
> msbuild -version
MSBuild version 17.14.23+b0019275e for .NET Framework
17.14.23.42201
> dotnet -version
10.0.102
Issue Description
I have files linked into my Resx file which is getting built into my project. When I change the contents of a text file and then save the resource is not regenerated when I build. However, something like an image file linked into my Resx will trigger resource generation upon changes.
Steps to Reproduce
demo-project.csproj:
TestResource.resx:
Referenced resources:
To reproduce the error:
Expected Behavior
My expectation is that changes to any
System.Resources.ResXFileRefshould cause the resource to be regenerated in the build.Actual Behavior
Instead, only changes to certain linked file types are causing the resource to be regenerated.
Analysis
I believe this is caused by ResXFile.GetLinkedFile here checking only for the type
FileStreamResource. Looking at MSBuildResXReader.GetResourcesFromFile the only way to get aFileStreamResourcereturned from that is for it NOT to be aStringor aByte[]or aMemoryStream.Logically, I would like for everything which is a
type="System.Resources.ResXFileRef"to be considered for triggering a regeneration of the resource file and not just the things which are NOTString/Byte[]/MemoryStream. Is the current implemented some kind of build optimization or speedup? If so, are there any switches I could use to turn it off?Versions & Configurations