Question

Environment: Visual studio 2012, MvcScaffolding

I'm new to MvcScaffolding and Powershell but what I'm trying to accomplish is to add a new Project to the solution of the current project. So basically the user has 1 solution, and 1 project in that solution, runs a scaffolding command and it generates a few other projects in that solution. I don't want to add an item to the current Project so Add-ProjectItemViaTemplate doesn't help me there. Is this the right technology to use here?

Was it helpful?

Solution

I did figure this out, but i don't believe this was the route I wanted to take. I'm opting for a custom multi-project Template to handle my project creations, and then using mvcscaffolding for the class generation later.

This code does work though to generate a created class library project into the current solution and was really hard for me to dig up so i'm posting it here

[T4Scaffolding.Scaffolder(Description = "Enter a description here")]                      [CmdletBinding()]
 param(        
[string]$Project,
[string]$CodeLanguage,
[string[]]$TemplateFolders,
[switch]$Force = $false
)
$slnName = [System.IO.Path]::GetFilename($dte.DTE.Solution.FullName)
$path = $dte.DTE.Solution.FullName.Replace($slnName,'').Replace('\\','\')
$sln = Get-Interface $dte.Solution ([EnvDTE80.Solution2]) 
$templatePath = $sln.GetProjectTemplate("ClassLibrary.zip","CSharp")
$sln.AddFromTemplate($templatePath, $path+'TestingLibGen','TestingLibGen')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top