I am trying to create a custom build task that will be invoked by overriding the "AfterResGen" target. The build task receives the list of files (FileWrites) and needs to go through all the build generated ".resources" files, deserialize them, manipulate them a bit and finally update them.
According to the Task documentation, the assembly containing the custom Task must be a netstandard2.0 project, so I've been trying that. However, reading and deserializing the ".resources" files (at that point on the obj folder since this is mid build) using either the ResourceReader type or the DeserializingResourceReader type, throw exception on every .resource file with "Stream is not a valid resource file". Debugging this down to the ResourceReader's exception, seems that some "MagicNumber" doesn't match. For the record, I do have System.Resources.Extensions v8.0.0 Nuget referenced on that netstandard2.0 project.
I have also attempted to create the build task in a net8 assembly but that fails loading of the assembly during the build, complaining that System.Runtime v8.0.0 can't be found. Interestingly, the net8 build task is loaded successfully during build using "dotnet build" outside of VS, so I guess this problem has to do with the inability of VS to load build tasks from net8 assemblies. I tried using TaskFactory="TaskHostFactory" on the UsingTask element in the .targets file, but then it just complains about inability to load some other assemblies so that doesn't work either.
At the moment, I'm stuck!
So, any thoughts on either a) How can I make the netstandard2.0 build task read the .resources files, deserialize and update during build or b) How can I make the net8 build task load and run when build is initiated from within Visual Studio ?
Palli