Hi Peter

Not sure about the <resources> section, because I hadn't noticed it before!
I'm gonna take a look at using <resources> later on this week.  In the
meantime, I'll describe below how we embed resources using NAnt.

We embed resources by nesting <arg> elements in the <csc> element.  I think
we stole this technique from NAnt's own build file.  One <arg> element is
required for each resource file that is to be embedded. The /resource
argument can accept both the path to the file and an identifier seperated by
a comma.  The identifier is the name given to the resource in the assembly
manifest (use ildasm.exe to view the manifest).

For example, imagine you have a web form called Main.aspx, in the namespace
Foobar with the form's resources stored in Main.resx.  The first thing you
have to do is convert the .resx file to a .resources file.  This can be done
using the <resgen> task that is now located in the NAntContrib project:

    <!-- compile xml resources -->
    <target name="resources" depends="init">
      <resgen input="${src.dir}/Main.resx"
output="${build.dir}/Main.resources"  />
    </target>

Once the .resources file has been generated, it needs to be embedded into
the assembly with the correct identifier.  Whilst I am not exactly sure
where the conventions are documented (if anyone knows then please can you
tell me), however I believe they are based on the associated class's fully
qualified name.  i.e. for the class Foobar.Main, the associated resources
are Foobar.Main.resources.

    <!-- compile core dll -->
    <csc target="exe" output="Foobar.exe">
      <references>
        <includes name="${lib.dir}/NUnitCore.dll" />
      </references>
      <sources basedir="${src.dir}">
        <includes name="**/*.cs" />
      </sources>
      <arg
value="/resource:${build.dir}/Main.resources,Foobar.Main.resources" />
    </csc>

I hope this helps.  Please checkout the NAnt build file or even our
Autonomy.NET [1] project build file for more examples of embedding resources
in assemblies.

Regards
Mark

[1] http://www.chive.com/products/autonomy

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Peter Slade
Sent: 09 July 2002 17:06
To: [EMAIL PROTECTED]
Subject: [Nant-users] Help understanding resources




Hi,
I have just started using nant to do csc project builds. I have figured out
how to get my projects to build with references/source, however I am
struggling with resources.
Is there any documentation and examples for how to use the <resources>
section? - The only thing I have found is the mention of resources in
http://nant.sourceforge.net/help/tasks/csctask.html
I have tried things such as:
<resources basedir="src/AppLib">
                <includes name="img_aboutbox.gif" />
                <includes name="img_application_icon.gif" />
                <includes name="img_back16x16.gif" />
</resources>
However, When I run my application I get the exception:
System.MissingManifestResourceException: Could not find any resources
appropriate for the specified culture (or the neutral culture) in the given
assembly. Make sure Login.resources was correctly embedded or linked into
assembly "AppLib".
Do I pass the .resx files to the resources tag?
Any help would be appreciated
Pete.



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Two, two, TWO treats in one.
http://thinkgeek.com/sf
_______________________________________________
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to