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.
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?
The references should be there, I didn't need them on the 2 projects I
had converted, because they were small single assmebly ones.
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?