Skip to content

Commit

Permalink
Used VSSDK to publish to the marketplace.
Browse files Browse the repository at this point in the history
  • Loading branch information
reduckted committed Dec 19, 2021
1 parent b200985 commit 9581049
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 57 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/publish-vs2022.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Publish Visual Studio 2022 Extension

on: workflow_dispatch

jobs:
publish-visual-studio:
runs-on: windows-2022

env:
Configuration: Release
DeployExtension: false

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup MSBuild
uses: microsoft/[email protected]

- name: Publish
working-directory: ./visual-studio
run: msbuild /t:PublishToMarketplace /Restore /v:Minimal /p:Configuration=Release /p:PersonalAccessToken=${{ secrets.PUBLISHER_TOKEN }}
48 changes: 24 additions & 24 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,27 @@ jobs:
PUBLISHER_TOKEN: ${{ secrets.PUBLISHER_TOKEN }}
run: node_modules/.bin/vsce publish -p $PUBLISHER_TOKEN

publish-visual-studio:
runs-on: windows-2022

env:
Configuration: Release
DeployExtension: false

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup MSBuild
uses: microsoft/[email protected]

- name: Build
working-directory: ./visual-studio
run: msbuild /t:Rebuild /Restore /v:Minimal

- name: Publish
uses: cezarypiatek/[email protected]
with:
extension-file: visual-studio\source\GitWebLinks\bin\Release\GitWebLinks.vsix
publish-manifest-file: visual-studio\publish.json
personal-access-code: ${{ secrets.PUBLISHER_TOKEN }}
# publish-visual-studio:
# runs-on: windows-2022

# env:
# Configuration: Release
# DeployExtension: false

# steps:
# - name: Checkout
# uses: actions/checkout@v2

# - name: Setup MSBuild
# uses: microsoft/[email protected]

# - name: Build
# working-directory: ./visual-studio
# run: msbuild /t:Rebuild /Restore /v:Minimal

# - name: Publish
# uses: cezarypiatek/[email protected]
# with:
# extension-file: visual-studio\source\GitWebLinks\bin\Release\GitWebLinks.vsix
# publish-manifest-file: visual-studio\publish.json
# personal-access-code: ${{ secrets.PUBLISHER_TOKEN }}
8 changes: 8 additions & 0 deletions build/set-version.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ try {
}

Write-Host "Updating Visual Studio extension..."
# Set the version in the props file.
$manifestFileName = Join-Path $root -ChildPath "visual-studio/source/GitWebLinks/source.extension.vsixmanifest"
$manifest = New-Object -TypeName System.Xml.XmlDocument
$manifest.PreserveWhitespace = $true
Expand All @@ -52,9 +53,16 @@ $identity = Select-Xml -Xml $manifest -XPath "/x:PackageManifest/x:Metadata/x:Id
([System.Xml.XmlElement]$identity.Node).SetAttribute("Version", $new.ToString())
$manifest.Save($manifestFileName)

# Set the version in the manifest's generated code-behind file.
$codeFileName = Join-Path -Path $root -ChildPath "visual-studio/source/GitWebLinks/source.extension.cs"
$code = Get-Content -Path $codeFileName -Raw
$code = $code -replace "public const string Version = `"[\d.]+`";", "public const string Version = `"$($new.ToString())`";"
Set-Content -Path $codeFileName -Value $code -NoNewLine

# Set the version in the assembly info.
$assemblyInfoFileName = Join-Path -Path $root -ChildPath "visual-studio/source/GitWebLinks/Properties/AssemblyInfo.cs"
$assemblyInfo = Get-Content -Path $assemblyInfoFileName -Raw
$assemblyInfo = $assemblyInfo -replace "Version\(`"[\d.]+`"\)", "Version(`"$($new.ToString()).0`")"
Set-Content -Path $assemblyInfoFileName -Value $assemblyInfo -NoNewLine

Write-Host "Done"
31 changes: 31 additions & 0 deletions visual-studio/build/PublishToMarketplace.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project>
<ItemGroup>
<PackageReference Update="Microsoft.VSSDK.BuildTools">
<GeneratePathProperty>true</GeneratePathProperty>
</PackageReference>
</ItemGroup>

<Target Name="PublishToMarketplace" DependsOnTargets="Rebuild">
<Message Text="Publishing extension to the marketplace..." Importance="high"/>

<Error
Condition="'$(Configuration)' != 'Release'"
Text="The configuration must be 'Release' when publishing to the marketplace."
/>

<PropertyGroup>
<VsixPublisher>$(PkgMicrosoft_VSSDK_BuildTools)\tools\vssdk\bin\VsixPublisher.exe</VsixPublisher>
<PublishManifestFileName>$(MSBuildThisFileDirectory)..\publish.json</PublishManifestFileName>
<ExtensionFileName>$(ProjectDir)$(TargetVsixContainer)</ExtensionFileName>
</PropertyGroup>

<Exec
Command="$(VsixPublisher) publish -personalAccessToken $(PersonalAccessToken) -payload $(ExtensionFileName) -publishManifest $(PublishManifestFileName)"
StandardOutputImportance="high"
StandardErrorImportance="high"
LogStandardErrorAsError="true"
/>

<Message Text="Finished publishing." Importance="high"/>
</Target>
</Project>
30 changes: 0 additions & 30 deletions visual-studio/build/SetVsixVersion.targets

This file was deleted.

2 changes: 1 addition & 1 deletion visual-studio/source/GitWebLinks/GitWebLinks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -254,5 +254,5 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildThisFileDirectory)..\..\build\SetVsixVersion.targets" />
<Import Project="$(MSBuildThisFileDirectory)..\..\build\PublishToMarketplace.targets" />
</Project>
4 changes: 2 additions & 2 deletions visual-studio/source/GitWebLinks/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("2.6.1.0")]
[assembly: AssemblyFileVersion("2.6.1.0")]
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]

0 comments on commit 9581049

Please sign in to comment.