T4 Scaffolding not working with visual studio 2015
Asked Answered
H

1

10

I have created a library of T4 scaffolding templates that i've used successfully in previous versions of visual studio, but now having upgraded my projects to VS 2015 I get the following error when opening the "Package Manager Console":

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

It seems that EnvDTE.DTE may not be supported out of the box anymore?

Is there anyway of resolving this issue or is there a new mechanism in VS 2015 that can run my existing T4 templates files.

My projects build and run fine.

Heti answered 8/8, 2015 at 7:11 Comment(2)
If the proposed answer solves your issue, why not to mark it as accepted then?Ardrey
Can you please provide feedback on whether this has resolved your issue please?Irrupt
I
10

FIX:

  1. Uninstall all 3 packages if you have them installed already
  2. Search NuGet Package Manager for 'MvcScaffolding.VS2015' and add it to the project
  3. Restart Visual Studio and the errors when starting up Package Manager Console will be gone.

For your interest the new packages can be found here:

If you simply install the MvcScaffolding package, the other packages will be pulled through. Hope this helps Nick. Please mark as answered if this resolves your issue.

----------------------------------------------------------------------------------

Additional Info: I received an email from Steve Sanderson (one of the main authors of T4Scaffolding / MVC Scaffolding):

I’m afraid MvcScaffolding/T4Scaffolding are no longer supported or maintained, as they were superseded by the ASP.NET scaffolding feature a few years back.

In case it helps, the source for MvcScaffolding/T4Scaffolding is at https://mvcscaffolding.codeplex.com/.

There were 2 options:

  1. Port existing scripts over to Asp.Net Scaffolding
  2. Take the source for MvcScaffolding and T4Scaffolding and fix the bug introduced by VS2013 and above.
Irrupt answered 19/8, 2015 at 8:32 Comment(21)
Another thought is to do a repair of VS2015 after you've installed the necessary Extensions. Almost as if the default EnvDTE reference is repaired with a default install. This has worked for me on occasion.Irrupt
Thanks John. I'll go through your recommendations and get back to you with my findings.Heti
Any updates on the issue? I am having the same problem on a brand new Windows 10 laptop with freshly installed VS 2015 and SQL Server 2014 SP1. I don't think I have any extensions although I'll verify.Hexangular
Hi Naomi. Yes I was able to reproduce this the other day with your described setup and have also been able to resolve it after completing a series of steps, so it is possible. I'm not sure exactly which steps were responsible for resolving the issue so I'm going to step back through them next week and try and get this resolved. Will post back next week with my findings. Cheers.Irrupt
Thanks a lot, David. So far I did install the latest Nu-Get package update and removed some of the extensions, but no joy yet. Will be waiting your instructions. Also I hope that t4 developers release an updated version in the meantime.Hexangular
The problem as described is a bit more serious than it first appears. When scaffolding is failing like this, right-clicking and saying "add view" or "add controller" is also broken or works oddly.Thermae
I repaired my VS install but still doesn't work. Looked into the delayed loading but I get the EnvDTE.DTE load error when i first go into the package console, well after VS has loaded. I set up a new MVC project and same error? I have some 30 projects in my solution and many packages so going through them is proving difficult. David sounds like you may have a solution. Could we have the steps.Heti
Thanks David. Good luck with a fix.Heti
Hi @NickReady. I've now uploaded NuGet packages that work with both Visual Studio 2013 & VS 2015. Can I please ask you to mark this question as answered if you've found it's solved your problem? Thanks.Irrupt
Hi David, Where did you upload your templates with a fix? Thanks a lot in advance.Hexangular
Hi Naomi, if you click the 3 packages in the list above, they each link to their respective NuGet Urls. Alternatively you can find them through NuGet Package Manager in Visual Studio if you search for 'MvcScaffolding.VS2015'. You only need to install this package and the others will be pulled through. Cheers.Irrupt
Hi Naomi, if you click the 3 packages in the list above, they each link to their respective NuGet Urls. Alternatively you can find the through NuGet Package Manager in Visual Studio if you search for 'MvcScaffolding.VS2015'. You only need to install this package and the others will be pulled through. Cheers.Irrupt
I finally got it to work. The trick was to manually uninstall previously installed scaffolding and install your new package into all projects afterwords. I didn't do it this way and spent lots of time resolving the problems. But now everything seems to work.Hexangular
Great glad you got there in the end. I'll update the comments to remind people to uninstall the old package first.Cheers.Irrupt
Why does it use this Successfully installed 'EntityFramework 4.1.10311.0'. Successfully added 'EntityFramework 4.1.10311.0' to SysManager.Scaffolding ? It is not the latest version of EF? Right now I'm trying to install the packages in my VS 2013.Hexangular
Our Scaffolding project had only T4 and T4 core in it, not MVC. So, it didn't have EF installed. Why T4 depends on EF now?Hexangular
Sorry for the late reply. T4Scaffolding has two scaffolders: EFDbContext & EFRepository. These depend on EntityFramework. If you're never going to use those scaffolders you should be able to remove the package from your project.Irrupt
Hi David, This Wednesday I upgraded to the latest through NuGet and now it's not working again - no errors, just not doing anything :(Hexangular
@Hexangular I believe there are issues using the most recent VS & NuGet updates. I'm afraid I'm pretty tied up over the next while so probably won't have the time to attend to this. Can I please ask that you raise this as a bug on the github project and include an example test project breaking it down to its simplest reproducible state? ThanksIrrupt
Hi David, where exactly should we raise a bug? My colleague reverted to the previous version of scaffolding so for now we're good. BTW, I tried to ask a separate question in regards to that here, but got a few down votes and then deleted it. It is by MS or something else? Thanks again. I also can not break it down to something simple, I'm afraid, but I can provide our Scaffolding project as is, if needed.Hexangular
Hi. You can raise a bug here: github.com/processedbeets/ASP.NET-MVC-Scaffolding Originally the source was written by MS employees. They have since stopped supporting it and hence why I took it on to fix the bugs I needed to get it working. That's the source you find above. If you're feeling like pitching in, I'd welcome you to dive in and have a go at fixing the issue. I could then merge into the main branch??Irrupt

© 2022 - 2024 — McMap. All rights reserved.