-
Notifications
You must be signed in to change notification settings - Fork 205
/
add-templatetypeparameter.ps1
40 lines (31 loc) · 1.49 KB
/
add-templatetypeparameter.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<#
# Name: add-templatetypeparameter.ps1
# Author: Tyler Hughes (RandomlyKnighted)
# Purpose: This script recursively goes through all VSTemplate files located in the SideWaffle project and adds a new
# Custom Parmeter to each template. This new Custom Paramter lets us know if the template being created is a
# project or item template.
# Last Updated: December 14, 2015
#>
$docsFolder = [environment]::getfolderpath("mydocuments") + "\Visual Studio 2015\Projects\side-waffle\Project Templates"
$files = Get-ChildItem $docsFolder *.vstemplate.xml -Recurse | % { $_.FullName }
foreach($filePath in $files)
{
[xml]$templateXml = Get-Content $filePath
$updatedFile = $false
'Processing [{0}]' -f $filePath | Write-Host
' Adding Telemetry Wizard' | Write-Host
# Create the new parameter element that will pass the template type to the wizard
$typeParameter = $templateXml.CreateElement($null, 'CustomParameter', 'http://schemas.microsoft.com/developer/vstemplate/2005')
$templateType = "Project"
# Set the values to their respective paramter elements
$typeParameter.SetAttribute("Name", "`$TemplateType`$")
$typeParameter.SetAttribute("Value", $templateType)
$templateXml.VSTemplate.TemplateContent.CustomParameters.AppendChild($typeParameter) | Out-Null
Write-Host ($templateXml)
$updatedFile = $true
if($updatedFile)
{
$templateXml.Save($filePath)
$updatedFile = $false
}
}