ASP.NET MVC 3 - 使用 MvcScaffolding 模板添加新控制器时出错
我正在尝试添加一个指定了以下模板的新控制器:
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
对正在发生的事情有什么想法吗?
I'm trying to add a new controller with the following template specified:
MvcScaffolding: Controller with read/write action and views, using repositories
This has worked in a previous project, but I'm now getting the following output from the Package Manager:
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
Any ideas on what's happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您安装 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 生成控制器 ->项目->右键->生成控制器它将作为用于控制器生成的 Visual Studio 插件工作,不使用 T4Scaffolding powershell 命令。
When you install the T4Scaffolding package it registers it's assemblies and contained cmdlets in the powershell host. For some reason it may load T4Scaffolding package from two different locations and you get "resolved to a cmdlet name that is ambiguous" error as powershell cannot decide which package cmdlet to execute.
As I see you execute template from "C:\Development\packages\MvcScaffolding.1.0.0\tools\RazorView\MvcScaffolding.RazorView.ps1" which seems like a global package and if you have MvcsScaffolding installed locally in your solution - (SolutionFolder)\packages\MvcScaffolding.1.0.0 powershell may load both packages.
If you generate controller from Visual Studio -> Project-> right button -> Generate controller it will works as Visual Studio plug in for controller generation does not use T4Scaffolding powershell commands.