Is MvcScaffolding VS 2015 compliant?

I recently upgraded to VS 2015 and now I get the following error when I try to use one of my forests:

Scaffold : Cannot get an instance of EnvDTE.DTE
At line:1 char:1
+ Scaffold Entity
+ ~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Invoke-Scaffolder], InvalidOperationException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.InvokeScaffolderCmdlet


It looks like there was a similar problem early on with VS 2013 , but the issue was resolved with Update 2.

Is there something I can do to get mvcScaffolding to work again or is there a new way that I should mimic my code?

Here's an example of one of my custom forests:


[T4Scaffolding.Scaffolder(Description = "Enter a description of RestApi here")][CmdletBinding()]
    [parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)][string[]]$EntityNames,
    [parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)][string]$Inherit,    
    [switch]$Force = $false

$outputPath = "ExampleOutput"  # The filename extension will be added based on the template <#@ Output Extension="..." #> directive
$namespace = (Get-Project $Project).Properties.Item("DefaultNamespace").Value
$baseInherit = $Inherit
if($Inherit -eq ""){
    $baseInherit = "BaseRestController"

foreach($EntityName in $EntityNames){
    $split = $EntityName.Split(":")
    $EntityName = $split[0]
        $Inherit = $split[1]
        $Inherit = $baseInherit;
    $Entities = Get-PluralizedWord $EntityName

    $outputPath = "ApiControllers\"+$Entities+"Api.cs"  # The filename extension will be added based on the template <#@ Output Extension="..." #> directive
    Add-ProjectItemViaTemplate $outputPath -Template RestApiTemplate `
        -Model @{ 
            Namespace = $namespace;
            Entity = $EntityName;
            Entities = $Entities;
            Inherit = $Inherit
        } `
        -SuccessMessage "Added RESTApi at {0}" `
        -TemplateFolders $TemplateFolders -Project $Project -CodeLanguage $CodeLanguage -Force:$Force



<#@ Template Language="C#" HostSpecific="True" Inherits="DynamicTransform" #>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using <#= Model.Namespace #>.Models;
using <#= Model.Namespace #>.Models.ViewModels;

namespace <#= Model.Namespace #>.ApiControllers {
    [RoutePrefix("api/<#= Model.Entities.ToLower() #>")]
    public class <#= Model.Entities #>Controller : <#= Model.Inherit #><<#= Model.Entity #>, <#= Model.Entity #>ViewModel> {
        public <#= Model.Entities #>Controller() : base("<#= Model.Entity #>"){

        // Use StandardActions to override standard behavior
        #region StandardActions
        // GetById, All, Add, Update, Delete


        // Use ExtendedActions to add additional behavior to the API
        #region ExtendedActions




source to share

1 answer

I faced this same error in VS2015. I pulled out the source, fixed the bugs, and downloaded new NuGet packages with associated dependencies. 3 new packages:

First uninstall MvcScaffolding and its dependencies, T4Scaffolding and T4Scaffolding.Core. If you then simply install the MvcScaffolding package , the other packages will be carried over. Hope this helps someone else.




All Articles