Skip to content

Instantly share code, notes, and snippets.

@sayedihashimi
Created January 21, 2015 03:31
Show Gist options
  • Save sayedihashimi/fd04142e167fffef514b to your computer and use it in GitHub Desktop.
Save sayedihashimi/fd04142e167fffef514b to your computer and use it in GitHub Desktop.
Update Visual Studio item templates to be available in ASP.NET 5 projects
$files = Get-ChildItem C:\Data\personal\mycode\side-waffle\TemplatePack\ItemTemplates\Web *.vstemplate -Recurse -Exclude C:\Data\personal\mycode\side-waffle\TemplatePack\ItemTemplates\Web\ASP.NET
foreach($filePath in $files){
[xml]$templateXml = Get-Content $filePath
$updatedFile = $false
'Processing [{0}]' -f $filePath | Write-Host
if($templateXml.VSTemplate.TemplateData.TemplateID){
' Found templateid'|write-host
}
else{
' Adding template id'|write-host
$templateId = $templateXml.CreateElement($null,'TemplateID','http://schemas.microsoft.com/developer/vstemplate/2005')
$templateId.InnerText = [guid]::NewGuid()
$templateXml.VSTemplate.TemplateData.AppendChild($templateId) | Out-Null
$updatedFile = $true
}
if($templateXml.VSTemplate.TemplateData.AppliesTo){
' Found AppliesTo'|write-host
}
else{
' Adding AppliesTo'|write-host
$appliesTo = $templateXml.CreateElement($null,'AppliesTo','http://schemas.microsoft.com/developer/vstemplate/2005')
$appliesTo.InnerText = 'ABC | (!ABC)'
$templateXml.VSTemplate.TemplateData.AppendChild($appliesTo)
$updatedFile = $true
}
if($updatedFile){
$templateXml.Save($filePath)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment