.targets file for MRContrib (Eleutian) code generator

1 view
Skip to first unread message

chriso

unread,
Apr 13, 2007, 12:00:49 PM4/13/07
to Castle Project Development List
I made a commit to the CodeGenerator project that contains a
default .targets file that can be used to enable MR Code generation in
your projects.

To use it you need to build the code generator from source (which will
copy the necessary files to your msbuildextensions folder). Then add
this to your MR project file:

<Import Project="$(MSBuildExtensionsPath)\Castle.Tools.CodeGenerator
\Castle.Tools.CodeGenerator.targets" />

This targets file will define item groups for your controllers and
views and also takes care of hooking the code generation task into
your build.

I use properties for everything so if you want to change something you
can just declare your property with the new value after you import the
file.

I was able to drop in replace this in 2 of my projects so far but if
you run into problems with it, please let me know.

Lee Henson

unread,
Apr 16, 2007, 1:50:38 PM4/16/07
to Castle Project Development List
I've just tried using this. I've hit a couple of issues which you
might have an opinion on:

1) The source cache seems to be case-sensitive. So having my
controller sources in "controllers" rather than "Controllers" causes
KeyNotFoundExceptions when attempting to obtain the parser. To fix
this I've .ToLower()-ed all _cache access. Is there a better way?

2) My project references aren't being picked up unless I add:

AssemblyReferences="@(ReferencePath);@(_ResolvedProjectReferencePaths)"

to the GenerateMonoRailSiteTreeTask xml in the .targets file. Do you
experience this behaviour?

chriso

unread,
Apr 16, 2007, 3:14:18 PM4/16/07
to Castle Project Development List
We could probably do this for case-insensitive
_cache = new
Dictionary<string,IParser>(StringComparer.CurrentCultureIgnoreCase)

The references should be there, I didn't need them on the 2 projects I
had converted, because they were small single assmebly ones.

Lee Henson

unread,
Apr 17, 2007, 7:48:09 AM4/17/07
to Castle Project Development List
> _cache = new
> Dictionary<string,IParser>(StringComparer.CurrentCultureIgnoreCase)

Yep this works fine. I also had to change the FindNode method in
DefaultTreeCreationService as shown below, as it was also doing a case
sensitive comparison on Name.

public TreeNode FindNode(string name)
{
foreach (TreeNode node in _nodes.Peek().Children)
{
if (string.Compare(node.Name, name, true) == 0)
{
return node;
}
}
return null;
}

Something else that I'm encountering at the moment is that my sources
appear to be cached on first compilation, and if (for example) I
change a view name, I have to close the solution and reopen before the
SiteMap correctly reflects that new name. I would have thought that
the Sources=@(Compile) bit meant that the sources list was reset on
each compilation?

Reply all
Reply to author
Forward
0 new messages