2

I've been developing an ASP.NET MVC 4 project for a while now and I've been using the "MVCScaffolding" package successfully but a few days ago I noticed that when creating a new controller for example the item for MVCScaffolding does not show up anymore. trying to run the scaffold command will also result in the following error:

The term 'scaffold' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:9
+ scaffold <<<< 
    + CategoryInfo          : ObjectNotFound: (scaffold:String) [], CommandNotFoundException

I've noticed that this problem has been mentioned several times on this page but no solutions have been provided.

Also the "MVCScaffolding" package could be used by other projects under the same environment in different solutions but not the same solution so I guess it is something specific to this solution. I've already tried uninstalling and reinstalling the packages manually or by the following commands, reinstalling nuget and restarting VS an windows several times :) ;

Uninstall-Package MvcScaffolding -RemoveDependencies
Install-Package MvcScaffolding

What I'm looking for is first and obviously how to resolve this specific issue and second, In general in such cases where should one be looking for in order to start debugging the problem? how does the command prompt determines whether or not a command is available?

Thanks in advance.

Bahador Izadpanah
  • 1,866
  • 1
  • 14
  • 13

3 Answers3

3

MVC Scaffolding defines the 'scaffold' command alias when a solution is opened in Visual Studio. The T4Scaffolding.Core NuGet package is the one that actually calls Set-Alias to do this in its init.ps1. You could check that the init.ps1 for the T4Scaffolding NuGet package is being run.

Matt Ward
  • 47,057
  • 5
  • 93
  • 94
  • 1
    Could you please elaborate on what you mean by "check if the init.ps1 is being run" so that I can check it tomorrow when I have access to the mentioned project, thank you very much. – Bahador Izadpanah Feb 06 '13 at 18:03
  • 1
    You could add a simple write statement to the init.ps1 file, which should be displayed on opening the solution when the Package Manager Console is open: Write-Warning "init.ps1 being called" – Matt Ward Feb 06 '13 at 20:33
  • 1
    thanks for being so helpful Matt :) the Write-Warning method put me in the right direction, for future reference after playing around with the init.ps1 files I noticed that the T4Scaffolding.1.0.8 and the T4Scaffolding.Core.1.0.0 folders in the packages folder of my solution were empty but not the mvcscaffolding. I still don't know why that happened after reinstalling the packages several times but copying the contents of those folders from another project was a quick remedy. on in short if you faced the same issue make sure that the folders for scaffolding packages are not empty. – Bahador Izadpanah Feb 07 '13 at 09:30
0

I know this post is really old.. but for those of you who are still facing this problem with VS2013, Please try the following:

  1. Uninstall-Package T4Scaffolding <-- If you have already used PM Console To Install it..

  2. Install by right clicking "references" -> Manage Nuget Packages -> Search for T4Scaffolding and install it from there..

By doing the above steps it worked like a charm for me

inN0Cent
  • 363
  • 2
  • 18
0

My Problem was solved by adding T4Scaffolding.Core through the NuGetPackage Manager. (version 1.0.8)