Running a script on NuGet Package Manager Console

2019-05-09 23:05发布

问题:

I'm using the MvcScaffolding NuGet Package to scaffold a couple of Controllers. I'm currently repeating the same process ie. Scaffold Controller MyController -Repository -Force. I do this for a number of controllers. Is there a way to run a script on the console where I can put a couple of commands and run them once?

回答1:

I'm a Powershell noob, so there may be a better way, but I just ran this in the Package Manager Console:

$controllers = "test", "test2"; foreach ($controller in $controllers) { echo $controller }

And it seemed to work, so maybe something like this would work?

$controllers = "test", "test2"; foreach ($controller in $controllers) { Scaffold Controller $controller -Repository -Force }