1
+
2
+ $VsixCs = Resolve-Path " .\*\Vsix.cs"
3
+ $VsixCsVersionPattern = ' VERSION = "([\d\\.]+)"'
4
+ $VsixCsVersionFormat = ' VERSION = "{0}"'
5
+
6
+ $SourceManifest = Resolve-Path " .\*\source.extension.vsixmanifest"
7
+ $PublishManifest = " .\publish.manifest.json"
8
+ $PublishVsixFile = Resolve-Path " .\*\bin\Release\*.vsix"
9
+
10
+
11
+ function UpdateVersion {
12
+ [cmdletbinding ()]
13
+ param (
14
+ [Parameter (Mandatory = $true )]
15
+ [string ] $Version
16
+ )
17
+
18
+ Write-Host " Update vsix version to :" $Version - ForegroundColor Green
19
+ UpdateVersionFile $Version
20
+ UpdateManifestVersion $Version
21
+ }
22
+
23
+ function UpdateVersionFile {
24
+ param (
25
+ [string ] $Version
26
+ )
27
+
28
+ (Get-Content $VsixCs ) | ForEach-Object {
29
+ if ($_ -cmatch $VsixCsVersionPattern ){
30
+ $_ -creplace $VsixCsVersionPattern , ($VsixCsVersionFormat -f $Version )
31
+ }
32
+ else {
33
+ $_
34
+ }
35
+ } | Set-Content $VsixCs - Encoding UTF8
36
+
37
+ Write-Host " Version updated:" $VsixCs - ForegroundColor Green
38
+ }
39
+
40
+ function UpdateManifestVersion {
41
+ param (
42
+ [string ] $Version
43
+ )
44
+
45
+ [xml ]$content = Get-Content $SourceManifest
46
+ $content.PackageManifest.Metadata.Identity.Version = $Version
47
+ $content.Save ($SourceManifest )
48
+
49
+ Write-Host " Version updated:" $SourceManifest - ForegroundColor Green
50
+ }
51
+
52
+ function PublishVsix {
53
+ [cmdletbinding ()]
54
+ param (
55
+ [Parameter (Mandatory = $true )]
56
+ [string ] $PAT
57
+ )
58
+
59
+ $installation = & " ${env: ProgramFiles(x86)} \Microsoft Visual Studio\Installer\vswhere.exe" - latest - prerelease - format json | ConvertFrom-Json
60
+ $path = $installation.installationPath
61
+ $vsixPublisher = Join-Path - Path $path - ChildPath " VSSDK\VisualStudioIntegration\Tools\Bin\VsixPublisher.exe" - Resolve
62
+ Write-Host " VsixPublisher:" $vsixPublisher - ForegroundColor Green
63
+
64
+ Write-Host " Publish Manifest:" $PublishManifest - ForegroundColor Green
65
+ Write-Host " Vsix:" $PublishVsixFile - ForegroundColor Green
66
+
67
+ & $vsixPublisher publish - payload $PublishVsixFile - publishManifest $PublishManifest - personalAccessToken $PAT - ignoreWarnings " VSIXValidatorWarning01,VSIXValidatorWarning02,VSIXValidatorWarning08"
68
+ }
69
+
70
+ Export-ModuleMember - Function UpdateVersion, PublishVsix
0 commit comments