Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
$item = "ConfigurationTransform";
$original = ".\$item.vsix";
$zip = "$";
$newZip = "$";
$newVsix = ".\$item.vs2015.vsix";
$folder = ".\$item";
$xmlPath = ".\$item\extension.vsixmanifest";
# zip 解凍
Rename-Item -Path $original -NewName $zip;
Expand-Archive $zip -DestinationPath $folder;
# xml 操作
[xml]$xml = Get-Content -Path $xmlPath;
$vs2015 = [xml]@"
<VisualStudio Version="14.0">
$xml.Vsix.Identifier.SupportedProducts.AppendChild($xml.ImportNode($vs2015.VisualStudio, $true));
# Remove garbage element xmlns=""
(Get-Content -Raw -Path $xmlPath).Replace('<VisualStudio Version="14.0" xmlns="">', '<VisualStudio Version="14.0">') | Out-File -FilePath $xmlPath -Encoding default
# .vsix 生成
# compress-archive だと vsix がこわれる ので手動か 7zip で!
# (ls $folder).FullName | Compress-Archive -DestinationPath $newZip;
. "$env:ProgramFiles\7-Zip\7z.exe" a -tzip $newZip (ls $folder).FullName;
Rename-Item -Path "$newZip" -NewName $newVsix;
Rename-Item -Path $zip -NewName $original;
Remove-Item -Path $folder -Recurse -Force;
. $newVsix;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment