This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$item = "ConfigurationTransform"; | |
$original = ".\$item.vsix"; | |
$zip = "$original.zip"; | |
$newZip = "$original.vs2015.zip"; | |
$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"> | |
<Edition>Ultimate</Edition> | |
<Edition>Premium</Edition> | |
<Edition>Pro</Edition> | |
</VisualStudio> | |
"@; | |
$xml.Vsix.Identifier.SupportedProducts.AppendChild($xml.ImportNode($vs2015.VisualStudio, $true)); | |
$xml.Save($xmlPath); | |
# 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