0

我正在尝试将 T4Scaffolding 用于我当前的项目,但一开始就失败了。

我在此链接上逐步执行相同的过程,该过程教如何将 T4Scaffolding 用于基本控制台应用程序。

我做的步骤

1-我创建了一个新的控制台应用程序(.NET 4.0)

2-我使用包管理器控制台成功安装了 T4Scaffholding (install-package t4scaffolding)

3-我尝试使用包管理器控制台创建一个演示自定义模板

Scaffold CustomScaffolder T4Demo

然后它抛出下面的异常

Add-ProjectItemViaTemplate : c:\Users\ryu\Desktop\SpiderWeb\ConsoleApplication2\packages\T4Scaffolding.Core.1.0.0\tools\CustomScaffolder\DefaultPs1Script.ps1.t4(1,48) : error CS0246: Com
piling transformation: The type or namespace name 'DynamicTransform' could not be found (are you missing a using directive or an assembly reference?)
At C:\Users\ryu\Desktop\SpiderWeb\ConsoleApplication2\packages\T4Scaffolding.Core.1.0.0\tools\CustomScaffolder\T4Scaffolding.CustomScaffolder.ps1:15 char:1
+ Add-ProjectItemViaTemplate $outputPath -Template DefaultPs1Script -Model @{
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Add-ProjectItemViaTemplate], Exception
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.AddProjectItemViaTemplateCmdlet

Add-ProjectItemViaTemplate : c:\Users\ryu\Desktop\SpiderWeb\ConsoleApplication2\packages\T4Scaffolding.Core.1.0.0\tools\CustomScaffolder\DefaultT4Template.cs.t4(1,48) : error CS0246: Com
piling transformation: The type or namespace name 'DynamicTransform' could not be found (are you missing a using directive or an assembly reference?)
At C:\Users\ryu\Desktop\SpiderWeb\ConsoleApplication2\packages\T4Scaffolding.Core.1.0.0\tools\CustomScaffolder\T4Scaffolding.CustomScaffolder.ps1:22 char:1
+ Add-ProjectItemViaTemplate $outputPath -Template DefaultT4Template -Model @{
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Add-ProjectItemViaTemplate], Exception
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.AddProjectItemViaTemplateCmdlet

我究竟做错了什么 ?

4

1 回答 1

1

在我将 Windows 区域设置从母语更改为美国后,问题就消失了。不要忘记重新启动 Visual Studio。

真是烦人的问题!

于 2013-03-29T11:16:05.523 回答