ASP.NET MVC 3 - 使用MvcScaffolding模板添加新Controller时出错

时间:2011-05-16 03:58:20

标签: asp.net-mvc-3 t4

我正在尝试使用指定的以下模板添加新控制器:

MvcScaffolding:具有读/写操作和视图的控制器,使用存储库

这在以前的项目中有效,但我现在从包管理器获得以下输出:

Scaffolding SubjectsController...
LibraryContext already has a member called 'Subjects'. Skipping...
Add-ProjectItemViaTemplate : The term 'Find-ScaffolderTemplate' resolved to a cmdlet name that is ambiguous. Possible m
atches include: T4Scaffolding\Find-ScaffolderTemplate T4Scaffolding\Find-ScaffolderTemplate.
At C:\Development\packages\T4Scaffolding.1.0.0\tools\EFRepository\T4Scaffolding.EFRepository.ps1:47 char:27
+ Add-ProjectItemViaTemplate <<<<  $outputPath -Template Repository -Model @{
    + CategoryInfo          : NotSpecified: (:) [Add-ProjectItemViaTemplate], CommandNotFoundException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.AddProjectItemViaTemplateCmdlet

Add-ProjectItemViaTemplate : The term 'Find-ScaffolderTemplate' resolved to a cmdlet name that is ambiguous. Possible m
atches include: T4Scaffolding\Find-ScaffolderTemplate T4Scaffolding\Find-ScaffolderTemplate.
At C:\Development\packages\MvcScaffolding.1.0.0\tools\Controller\MvcScaffolding.Controller.ps1:106 char:27
+ Add-ProjectItemViaTemplate <<<<  $outputPath -Template $templateName -Model @{
    + CategoryInfo          : NotSpecified: (:) [Add-ProjectItemViaTemplate], CommandNotFoundException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.AddProjectItemViaTemplateCmdlet

Add-ProjectItemViaTemplate : The term 'Find-ScaffolderTemplate' resolved to a cmdlet name that is ambiguous. Possible m
atches include: T4Scaffolding\Find-ScaffolderTemplate T4Scaffolding\Find-ScaffolderTemplate.
At C:\Development\packages\MvcScaffolding.1.0.0\tools\RazorView\MvcScaffolding.RazorView.ps1:49 char:27
+ Add-ProjectItemViaTemplate <<<<  $outputPath -Template $Template -Model @{
    + CategoryInfo          : NotSpecified: (:) [Add-ProjectItemViaTemplate], CommandNotFoundException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.AddProjectItemViaTemplateCmdlet

Add-ProjectItemViaTemplate : The term 'Find-ScaffolderTemplate' resolved to a cmdlet name that is ambiguous. Possible m
atches include: T4Scaffolding\Find-ScaffolderTemplate T4Scaffolding\Find-ScaffolderTemplate.
At C:\Development\packages\MvcScaffolding.1.0.0\tools\RazorView\MvcScaffolding.RazorView.ps1:49 char:27
+ Add-ProjectItemViaTemplate <<<<  $outputPath -Template $Template -Model @{
    + CategoryInfo          : NotSpecified: (:) [Add-ProjectItemViaTemplate], CommandNotFoundException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.AddProjectItemViaTemplateCmdlet

Add-ProjectItemViaTemplate : The term 'Find-ScaffolderTemplate' resolved to a cmdlet name that is ambiguous. Possible m
atches include: T4Scaffolding\Find-ScaffolderTemplate T4Scaffolding\Find-ScaffolderTemplate.
At C:\Development\packages\MvcScaffolding.1.0.0\tools\RazorView\MvcScaffolding.RazorView.ps1:49 char:27
+ Add-ProjectItemViaTemplate <<<<  $outputPath -Template $Template -Model @{
    + CategoryInfo          : NotSpecified: (:) [Add-ProjectItemViaTemplate], CommandNotFoundException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.AddProjectItemViaTemplateCmdlet

Add-ProjectItemViaTemplate : The term 'Find-ScaffolderTemplate' resolved to a cmdlet name that is ambiguous. Possible m
atches include: T4Scaffolding\Find-ScaffolderTemplate T4Scaffolding\Find-ScaffolderTemplate.
At C:\Development\packages\MvcScaffolding.1.0.0\tools\RazorView\MvcScaffolding.RazorView.ps1:49 char:27
+ Add-ProjectItemViaTemplate <<<<  $outputPath -Template $Template -Model @{
    + CategoryInfo          : NotSpecified: (:) [Add-ProjectItemViaTemplate], CommandNotFoundException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.AddProjectItemViaTemplateCmdlet

Add-ProjectItemViaTemplate : The term 'Find-ScaffolderTemplate' resolved to a cmdlet name that is ambiguous. Possible m
atches include: T4Scaffolding\Find-ScaffolderTemplate T4Scaffolding\Find-ScaffolderTemplate.
At C:\Development\packages\MvcScaffolding.1.0.0\tools\RazorView\MvcScaffolding.RazorView.ps1:49 char:27
+ Add-ProjectItemViaTemplate <<<<  $outputPath -Template $Template -Model @{
    + CategoryInfo          : NotSpecified: (:) [Add-ProjectItemViaTemplate], CommandNotFoundException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.AddProjectItemViaTemplateCmdlet

Add-ProjectItemViaTemplate : The term 'Find-ScaffolderTemplate' resolved to a cmdlet name that is ambiguous. Possible m
atches include: T4Scaffolding\Find-ScaffolderTemplate T4Scaffolding\Find-ScaffolderTemplate.
At C:\Development\packages\MvcScaffolding.1.0.0\tools\RazorView\MvcScaffolding.RazorView.ps1:49 char:27
+ Add-ProjectItemViaTemplate <<<<  $outputPath -Template $Template -Model @{
    + CategoryInfo          : NotSpecified: (:) [Add-ProjectItemViaTemplate], CommandNotFoundException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.AddProjectItemViaTemplateCmdlet

有关正在发生的事情的任何想法?

1 个答案:

答案 0 :(得分:0)

安装T4Scaffolding软件包时,它会在powershell主机中注册它的程序集并包含cmdlet。由于某种原因,它可能从两个不同的位置加载T4Scaffolding包,并且您“解析为一个不明确的cmdlet名称”错误,因为powershell无法决定执行哪个包cmdlet。 我看到你从“C:\ Development \ packages \ MvcScaffolding.1.0.0 \ tools \ RazorView \ MvcScaffolding.RazorView.ps1”执行模板,它看起来像一个全局包,如果你在你的解决方案中本地安装了MvcsScaffolding - (SolutionFolder )\ packages \ MvcScaffolding.1.0.0 powershell可以加载两个包。

如果从Visual Studio生成控制器 - &gt;项目 - &GT;右键 - &gt;生成控制器它将作为Visual Studio插件用于控制器生成不使用T4Scaffolding powershell命令。