Nant and embedding strongly-typed resources for .NET 2.0

I spent some time trying to figure out how to embed my strongly-typed resources (.resx) files using NAnt this morning as the default <resources> element of the <csc> task does not enable you to pass the /str argument to the resgen application to make strongly-typed resources. I found a work-around that I figured I would post.
Set a property to the location of the ResGen.exe for the 2.0 version of the executable.
<property name="resgen.exe" value="C:Program FilesMicrosoft Visual Studio 8SDKv2.0BinResGen.exe" />


and then, in the target:

<target name="build">


<exec program="${resgen.exe}" workingdir=".">

        <arg line="SourceApplicationProjectResourcesMyResource.resx SourceApplicationProjectResourcesMyResource.resources /str:cs" />


    <csc target="library" output="${build.dir}/${}.dll" debug="${debug}">


            <include name="${source.dir}/**.cs"/>






include name="${source.dir}/**.resources"/>








Tests run appropriately now that the resource has been embedded properly.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s