15

在 vs2012 中,我曾经使用 Steve Sanderson 的 mvcScaffolding和这个包,我可以用单元测试和控制器用存储库和依赖注入来构建动作方法。我的问题很简单。在vs2013中有没有办法做到这一点?当我在 vs2013 中安装软件包时,出现以下错误:

Set-DefaultScaffolder : Cannot get an instance of EnvDTE.DTE
At C:\dev\WebApplication2\packages\T4Scaffolding.Core.1.0.0\tools\init.ps1:50 char:9
+         Set-DefaultScaffolder -Name CustomTemplate -Scaffolder T4Scaffolding.Cus ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-DefaultScaffolder], InvalidOperationException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet

Set-DefaultScaffolder : Cannot get an instance of EnvDTE.DTE
At C:\dev\WebApplication2\packages\T4Scaffolding.Core.1.0.0\tools\init.ps1:51 char:9
+         Set-DefaultScaffolder -Name CustomScaffolder -Scaffolder T4Scaffolding.C ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-DefaultScaffolder], InvalidOperationException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet

Set-DefaultScaffolder : Cannot get an instance of EnvDTE.DTE
At C:\dev\WebApplication2\packages\T4Scaffolding.1.0.8\tools\init.ps1:6 char:1
+ Set-DefaultScaffolder -Name DbContext -Scaffolder T4Scaffolding.EFDbContext -Sol ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-DefaultScaffolder], InvalidOperationException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet

Set-DefaultScaffolder : Cannot get an instance of EnvDTE.DTE
At C:\dev\WebApplication2\packages\T4Scaffolding.1.0.8\tools\init.ps1:7 char:1
+ Set-DefaultScaffolder -Name Repository -Scaffolder T4Scaffolding.EFRepository -S ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-DefaultScaffolder], InvalidOperationException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet

Set-DefaultScaffolder : Cannot get an instance of EnvDTE.DTE
At C:\dev\WebApplication2\packages\MvcScaffolding.1.0.9\tools\init.ps1:47 char:1
+ Set-DefaultScaffolder -Name Controller -Scaffolder MvcScaffolding.Controller -So ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-DefaultScaffolder], InvalidOperationException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet

Set-DefaultScaffolder : Cannot get an instance of EnvDTE.DTE
At C:\dev\WebApplication2\packages\MvcScaffolding.1.0.9\tools\init.ps1:48 char:1
+ Set-DefaultScaffolder -Name Views -Scaffolder MvcScaffolding.Views -SolutionWide ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-DefaultScaffolder], InvalidOperationException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet

Set-DefaultScaffolder : Cannot get an instance of EnvDTE.DTE
At C:\dev\WebApplication2\packages\MvcScaffolding.1.0.9\tools\init.ps1:49 char:1
+ Set-DefaultScaffolder -Name Action -Scaffolder MvcScaffolding.Action -SolutionWi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-DefaultScaffolder], InvalidOperationException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet

Set-DefaultScaffolder : Cannot get an instance of EnvDTE.DTE
At C:\dev\WebApplication2\packages\MvcScaffolding.1.0.9\tools\init.ps1:50 char:1
+ Set-DefaultScaffolder -Name UnitTest -Scaffolder MvcScaffolding.ActionUnitTest - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-DefaultScaffolder], InvalidOperationException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet

Set-DefaultScaffolder : Cannot get an instance of EnvDTE.DTE
At C:\dev\WebApplication2\packages\MvcScaffolding.1.0.9\tools\init.ps1:54 char:1
+ Set-DefaultScaffolder -Name View -Scaffolder $viewScaffolder -SolutionWide -DoNo ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-DefaultScaffolder], InvalidOperationException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.SetDefaultScaffolderCmdlet
4

5 回答 5

9

我们正在迁移到一个新的脚手架系统,但现在,以管理员身份运行 VS 并使用我们更新的这个-pre 版本:

安装包 MvcScaffolding -版本 1.0.8-vs2013 -Pre

我会写这个。

于 2014-02-12T01:39:00.200 回答
2

您得到的错误是它无法创建 VS IDE (EnvDTE.DTE) 的实例。该脚手架包引用了旧版本的 VS IDE,因此它在 VS2013 中不起作用。该项目必须更新以正确支持 VS2013。

codeplex 项目看起来很长一段时间没有更新,所以我的猜测是,除非项目移动到不同的开源存储库,否则它已经死了。

由于 ASP.NET 现在已经内置了自己的脚手架,我建议是时候进行转换了。

于 2013-11-05T17:31:23.030 回答
2

在命令行中试试这个: cd C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ devenv.exe /setup "Extensions\Microsoft\Web\Mvc\Scaffolding\Microsoft.AspNet.Scaffolding.Mvc.5.0 .dll"

于 2013-12-09T01:57:32.370 回答
1

为了解决 VS2013 Update 4 上的这个问题,我必须从所有模块中卸载 .\packages 目录删除所有 T4*,退出 VS。

再次输入,并使用 wittness 的解决方案,在包管理器控制台上执行:Install-Package MvcMailer-vs2013 -pre,瞧,从那时起它的工作......

感谢一切

于 2015-06-04T16:50:11.593 回答
1

我知道这是不久前发布的,但是,我在使用 MvcScaffolding 时在 VS2015 中遇到了同样的错误。实际的错误在于 T4Scaffolding.Core 包。我提取了源代码,修复了错误,并上传了带有链接依赖项的新 NuGet 包。3个新包是:

首先卸载 MvcScaffolding 及其依赖项、T4Scaffolding 和 T4Scaffolding.Core。如果您然后简单地安装MvcScaffolding包,其他包将被拉出。希望这对其他人有帮助。

干杯。

于 2015-09-28T16:42:56.743 回答