T4Toolbox.tt missing from generated project

1,240 views
Skip to first unread message

fmorriso

unread,
Mar 11, 2009, 2:33:25 PM3/11/09
to S#arp Architecture
I must preface this discussion by saying I found out that my
installation of VisualSVN and T4Toolbox are incompatible as far as
using Sharp-Architecture, but not until I reached page 39 of the
instructions (Hint: move that "little show-stopper" to the front of
the doc). I subsequently uninstalled VisualSVN (both client and
server) but *DID NOT* create my Visual Studio 2008 project again, so
slap me silly right away if this "technique" hasn't got a prayer of
succeeding. Also, I use the Clarius Pro Edition for the T4 Editor, if
that makes any difference.

I created a new Sharp-Archicture project following the guidelines in
the 2009-03-11 edition of the documentation and all seemed well until
I got to the step (#4 as it turns out) which calls for me to modify
the ScaffoldingGeneratorCommand.tt file. I should have known there
was going to be a problem when I see the red underline of this line of
code:

<#@ include file="T4Toolbox.tt" #>

Sure enough, it generates the following error when I right-click and
choose Preview Transformation:

Error: Could not find file 'C:\Projects\FordVechicleProductionTracker
\tools\CrudScaffolding\T4Toolbox.tt'.Try using a rooted path instead.,
line: 4 column: 4

I searched my computer and find the only copy of T4Toolbox.tt is
located in directory %programfiles%\T4 Toolbox\.

For the time being, should I just copy the missing file to where it is
expected? Is this a true bug or more of my own doing for failing to
notice the problem that is not mentioned until page 39 of the 51 page
document that I need to first uninstall VisualSVN before I can do CRUD
scaffolding?

Billy

unread,
Mar 11, 2009, 4:14:08 PM3/11/09
to S#arp Architecture
I will certainly move the documentation about the incompatibilities
into the earlier section entitled "Installing and Configuring
Prerequisites." Kyle Baley seems to have resolved his issues with
VisualSVN, perhaps by using the latest version of it (I just sent him
a question about what he did to resolve this).

Here's what I'd recommend trying:

1) Copy T4Toolbox.tt to the appropriate location and see if that
brings a quick resolution. (You shouldn't normally have to do this,
but it may fix the problem you're encountering.)

2) If the previous step didn't work, try uninstalling Clarius and
T4Toolbox. Then, reinstall T4Toolbox as a minimum and then reinstall
Clarius, in that order.

In addition to reorganizing the documentation, I'll also work to get
updated status from these vendors concerning the third party
incompatibility issues and find out if a resolution might be coming.
To give you a heads up, there's one other CRUD generation problem that
we've encountered, which I'm waiting to hear back from the developer
behind T4 on how we might be able to resolve (http://code.google.com/p/
sharp-architecture/issues/detail?id=77).

Thanks for your patience as we resolve these few remaining items.

Billy McCafferty

fmorriso

unread,
Mar 11, 2009, 4:43:43 PM3/11/09
to S#arp Architecture
For the scaffolding to work I had to:
1. copy %programfiles%\T4 Toolbox\T4Toolbox\ to C:\Projects
\FordVehicleProductionTracking\tools\CrudScaffolding\
2. copy %programfiles%\T4 Toolbox\T4Toolbox.tt to C:\Projects
\FordVehicleProductionTracking\tools\CrudScaffolding\

Perhaps whatever technique you use to figure out if/where T4 Toolbox
is installed needs to be verified or at least some error checking that
screams "Hey! I cannot find where you installed T4 Toolbox".

I am also seeing some (nice as it turns out because you already auto-
generate a lot of the necessary code) mismatches with what needs to be
done to use Fluent NHibernate in Appendix B vs. what I actually ended
up doing. Some of the steps called for seem to have already been
performed while others, like how to modify RouteRegister are still
unclear to me.

In my simple example, I have a SQL Server database with one table
named BodyStyle defined thusly:

CREATE TABLE [dbo].[BodyStyle](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Description] [varchar](50) NOT NULL,
[BodyCode] [char](3) NOT NULL,
[OrderCode] [char](4) NOT NULL,
[IsHybrid] [bit] NOT NULL,
CONSTRAINT [PK_BodyStyle] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY
= OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

The corresponding one-time scaffolding I performed via the tt tool
looks like this:

EntityScaffoldingDetails entityScaffoldingDetails =
new EntityScaffoldingDetails("BodyStyle");

/*
* Property names should be PascalCase.
* Do not include a property for Id as it will be included
automatically.
*/
entityScaffoldingDetails.EntityProperties.Add(
new EntityProperty("Description", "string", string.Empty,
"[NotNull, NotEmpty]", false)
);
entityScaffoldingDetails.EntityProperties.Add(
new EntityProperty("BodyCode", "string", string.Empty, "[NotNull,
NotEmpty]", false)
);
entityScaffoldingDetails.EntityProperties.Add(
new EntityProperty("OrderCode", "string", string.Empty, "[NotNull,
NotEmpty]", false)
);
entityScaffoldingDetails.EntityProperties.Add(
new EntityProperty("IsHybrid", "bool", false, "[NotNull]", false)
);

///////////////////////////////////////////////////

// The first parameter should reflect the root directory of your
solution
ScaffoldingGenerator generator = new ScaffoldingGenerator(
@"C:\Projects\FordVehicleProductionTracking\",
"FordVehicleProductionTracking", entityScaffoldingDetails);

Everything works fine until I run the NUnit test named
CanConfirmDatabaseMatchesMappings in MappingIntegrationTests, which
never gets passed the Setup step, which is defined as:

[SetUp]
public virtual void SetUp()
{
string[] mappingAssemblies =
RepositoryTestsHelper.GetMappingAssemblies();
NHibernateSession.Init(new SimpleSessionStorage(),
mappingAssemblies,
new AutoPersistenceModelGenerator().Generate(),
"../../../../app/FordVehicleProductionTracking.Web/
NHibernate.config");
}

And results in the following error:

An exception occurred during configuration of persistence layer.

The NHibernate.config file looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.connection_string">Data
Source=.;Database=FordVehicleProductionTracking;Integrated
Security=True;MultipleActiveResultSets=True;</property>
<property name="dialect">NHibernate.Dialect.MsSql2005Dialect</
property>
<property
name="connection.provider">NHibernate.Connection.DriverConnectionProvider</
property>
<property
name="connection.driver_class">NHibernate.Driver.SqlClientDriver</
property>
<property name="show_sql">false</property>
<property name="connection.release_mode">auto</property>
<property name="adonet.batch_size">500</property>

<!-- Mapping assemblies -->
<!-- Can't map it for Fluent NHibernate here; instead, load the
mapping assembly in Global.asax.cs.
If you're still using HBMs, you can use the mapping here or pass
the assembly via Global.asax.cs
as well, just like you can do with the Fluent NHibernate assembly
(s). -->
<!-- mapping assembly="FordVehicleProductionTracking.Data" -->
</session-factory>
</hibernate-configuration>

I'll try the uninstall/reinstall sequence you suggest and see if that
affects anything.

Eventually, when the unit tests start working, I'll see if I can
unravel the mystery of Routes, which I presently have set up as
follows, based on the auto-generated BodyStylesController.cs and the
auto-generated BodyStyle.cs classes:

namespace FordVehicleProductionTracking.Web.Controllers
{
public class RouteRegistrar
{
public static void RegisterRoutesTo(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?
favicon.ico(/.*)?" });

// The areas below must be registered from greater
subareas to fewer;
// i.e., the root area should be the last area registered

routes.CreateArea("BodyStyle",
"FordVehicleProductionTracking.Web.Controllers.BodyStylesController",
routes.MapRoute(null, "BodyStyle/{controller}/
{action}", new { action = "Index" }),
routes.MapRoute(null, "BodyStyle/{controller}/{action}/
{id}")
);

// Routing config for the root area
routes.CreateArea("Root",
"FordVehicleProductionTracking.Web.Controllers",
routes.MapRoute(null, "{controller}/{action}", new
{ controller = "Home", action = "Index" })
);
}
}
}

I'm really beginning to appreciate the huge amount of heavy lifting
you've done. It's pretty fantastic, even when compared to ASP.Net
Dynamic Data, which is wedded to Microsoft's proprietary Linq To SQL
and EF technologies. It's nice to have the alternative to use
NHibernate + Fluent-NHibernate with ASP.Net MVC.

P.S. The example I wrote is not something I built for Ford. I was
forced to wait six months to get my new 2009 Ford Escape Hybrid, so I
wrote a small tracking system while I was waiting and used Microsoft's
ASP.Net Dynamic Data architecture to make data entry easier. Now I
want to see if I can move it over to S#harp Architecture so I can
compare the two.
> > scaffolding?- Hide quoted text -
>
> - Show quoted text -

Billy

unread,
Mar 11, 2009, 7:25:02 PM3/11/09
to S#arp Architecture
You were one step ahead of me. I've just checked an update to the
documentation for the RC 2 release. It may be found at
http://sharp-architecture.googlecode.com/svn/trunk/docs/

Concerning the routing:

> routes.CreateArea("BodyStyle",
> "FordVehicleProductionTracking.Web.Controllers.BodyStylesController",
> routes.MapRoute(null, "BodyStyle/{controller}/
> {action}", new { action = "Index" }),
> routes.MapRoute(null, "BodyStyle/{controller}/{action}/
> {id}")
> );

You don't need to add a route for each controller, only a new route
for each "area." So if you prefix an Entity name with a namespace,
then, and only then, do you need to add a route to RouteRegistrar. If
you simply added a new Entity with no namespace prefix, e.g., passed
"BodyStyle" to the constructor of EntityScaffoldingDetails, then
there's no need to mess with RouteRegistrar. Alternatively, if you
had passed something like "CarDetailing.BodyStyle", then you'd have to
create a new route in RouteRegistrar, e.g.,

routes.CreateArea("CarDetailing",
"FordVehicleProductionTracking.Web.Controllers.CarDetailing",
routes.MapRoute(null, "CarDetailing/{controller}/{action}", new
{ action = "Index" })
);

Let me know if this doesn't clear it up.

Thanks,
Billy

Kyle Baley

unread,
Mar 11, 2009, 10:17:30 PM3/11/09
to sharp-arc...@googlegroups.com
I've resolved my VisualSVN issue, they've released a test version that
seems to fix the incompatibility 'twixt it and T4
(http://groups.google.com/group/visualsvn/browse_thread/thread/61eb05494acaab01).
That said, I haven't been able to get the scaffolding to work
consistently either. Haven't had a chance to debug the issue but it's
chronicled around here somewhere.

Billy

unread,
Mar 11, 2009, 10:30:14 PM3/11/09
to S#arp Architecture
Kyle,

I believe I've duplicated the issue you're running into and have
raised an issue on the T4 Toolbox website:
http://t4toolbox.codeplex.com/WorkItem/View.aspx?WorkItemId=12794

I've been in contact with Oleg Sych, the developer of T4 Toolbox. He
says that he believes this issue is resolved in the next version of T4
Toolbox, but that we will unlikely to have a releasable version of it
within the coming week or two. The work around that I have found is
to be sure to close the ScaffoldingGeneratorCommand.tt between uses.
This seems to "clear" something or other and gets rid of the
exception.

Billy


On Mar 11, 8:17 pm, Kyle Baley <k...@baley.org> wrote:
> I've resolved my VisualSVN issue, they've released a test version that
> seems to fix the incompatibility 'twixt it and T4
> (http://groups.google.com/group/visualsvn/browse_thread/thread/61eb054...).
> That said, I haven't been able to get the scaffolding to work
> consistently either. Haven't had a chance to debug the issue but it's
> chronicled around here somewhere.
>
> ...
>
> read more »

Kyle Baley

unread,
Mar 11, 2009, 10:36:45 PM3/11/09
to sharp-arc...@googlegroups.com
Bah! This is hampering my ability to create dimecasts. Do you know if
it works with an earlier version of T4?

On 3/11/09, Billy <wmcca...@gmail.com> wrote:
>

Billy

unread,
Mar 11, 2009, 11:38:26 PM3/11/09
to S#arp Architecture
I've tested this with versions 8.11.12.1, 8.12.27.1, and 9.1.20.1 -
all have the exact same behavior. I'm amazed that I hand't
encountered this on a regular basis before.

To reproduce is very straight forward:
1) Use ScaffoldingGeneratorCommand.tt to generate CRUD scaffolding and
reload the projects when prompted
2) WIthout closing the file, try to generate a different entity -
you'll encounter the exception

To work around it is just as straight forward:
1) Use ScaffoldingGeneratorCommand.tt to generate scaffolding and
reload the projects when prompted
2) Close and reopen ScaffoldingGeneratorCommand.tt in Visual Studio
(no need to actually close Visual Studio...just close/reopen the file)
3) Generate a different entity without a problem

Hoping Oleg is right in believing he's resolved this.

Billy


On Mar 11, 8:36 pm, Kyle Baley <k...@baley.org> wrote:
> Bah! This is hampering my ability to create dimecasts. Do you know if
> it works with an earlier version of T4?
>
> ...
>
> read more »
Reply all
Reply to author
Forward
0 new messages