This project is read-only.

Resgen's limitation in compiling resource files

Jan 30, 2009 at 6:40 AM
Hi everyone,

I've been developing a feature for npanday to support resx files. I've edited the maven-resgen-plugin so that it can compile the resx file to resource files and in turn this resource file will be use in compiling the project (with csc).  the maven-resgen-plugin is actually calling the resgen.exe, the parameters to execute this is the resx file and the output filename of the resource. (resgen form1.resx,mynamespace.myclassname.resource). if u didnt add the outputfilename the default name would be the name of the sourcefile(form1.resource).  the problem occurs if CSC is executed, because as requirements of attaching a resource in the compiler, the filename of the resource should be the MyNamespace.MyClassname.resource. so if the resource file is not of the correct name, the build will fail.

my solution so far is adding the MyNamespace.MyClassname in the pom.xml. this is how the plugin is added.

as you can see in bold letters the expected file name if the resource file.
with this the build will successful.
now the problem is in the project importer, i cant get the Namespace and Classname that is needed for the pom. because the only info i get is the filename of the resx file and the .cs file that needs which can be retrieve in the project file.
    <EmbeddedResource Include="Form1.resx">

so what i need to know is how can i get the namespace and classname of the .cs file so that i can use it in executing resgen.exe

additional info:
when i was looking for the solution for this. i came accross with MSBUILD.exe. if you build the project using msbuild there is a part there where the resources are created(CoreResgen) but i dont know how msbuild is doing this. he actually get the name of the resource file correct. and placing it in the obj folder. i alread posted a question in MSDN Forums and still waiting for a  reply.
Feb 2, 2009 at 9:01 AM
during the import of the project you can parse the .cs file and with a RegEx search for the namespace.
An other approach could be by reflection/code dom generator, but without having a fully compiled project this will be difficult.
Do you think it is possible to parse the .cs file?
Feb 3, 2009 at 5:03 AM
thank you for your suggestion ermanov1

it would be really difficult and task full for the importer to open each .cs file that has an attach resx file. specially if it is a very large project with a lot of resx files. it will eat process time and resources. i don't agree using it. and one of the purpose of npanday/maven is to handle large scale projects.

i already posted a question on MSDN on how to do this, but after 4 days, i havent got a reply so far.

i was thinking of using msbuild to build the project, since msbuild is creating the resource within its process and do most of the compiling task. but this is something that will need time to implement and TEST.
Feb 3, 2009 at 7:58 AM
I have a question, on windows with visual studio, do you think it is possible to compile directly the original visual studio project?
After compile (with all, resources, embedded files, configurations, etc.) the plugin could take the whole output (in bin\debug or bin\release) and put in the target folder.
Feb 3, 2009 at 8:45 AM
yes it is.

you can build a .sln, .csproj and .vbproj with msbuild.exe.
its somewhere here. "C:\WINDOWS\Microsoft.NET\Framework\v3.5\" if you want to use the 3.5 framework.

for more info on msbuild click here.

C:\WINDOWS\Microsoft.NET\Framework\v3.5\msbuild myproject.csproj /target:build
will actually compile the whole project and will create necessary files for the project.

i was thinking using this for building projects for npanday.  but this is something to be discussed more.
Feb 3, 2009 at 9:50 AM
You can support all two systems in the configuration.
What do you think about this?

Feb 3, 2009 at 9:54 AM
what do you mean by two systems?
can you elaborate more?
Feb 3, 2009 at 10:03 AM
I mean a setting in pom.xml (or other???) to activate during compile the use of MSBUILD or not.
If you do not use MSBUILD the standard (actual) systems works otherwise the whole project is compiled by MSBUILD.
Feb 3, 2009 at 10:19 AM
but i don't see the point in creating a trigger or a configuration for this.
npanday will build the project through pom.xml files and VS2008 can build it with just the project.

npanday will read the pom.xml, download what is needed(if its not in the repository yet and build the project. it will do what VS does and more. like handling artifacts.

but the current npanday is using csc/vbc in building projects not the msbuild, cause from what i heard msbuild is shipped with VS not by the .netframework but the csc/vbc and even the resgen can be installed even without the VS.(i haven't really verified this yet)

that is why the current npanday uses only csc/vbc and not the msbuild.
i'm actually aiming to use msbuild for npanday.

csc is use to compile .cs files whule vbc is use to compile vb project.

Feb 4, 2009 at 5:57 AM
I just looked and it appears that msbuild ships with the SDK along with csc and vbc.
Feb 4, 2009 at 6:02 AM
i'm actually trying it now.
i'm creating a plugin that will build the project using msbuild.