I recently switched Start Screen, my Visual Studio extension, to publish updates without a stored Marketplace Personal Access Token (PAT). The extension still builds, runs its tests, and ships through GitHub Actions. What changed is how the publishing job proves it is allowed to publish. I made the same workflow change for EditorConfig too.
This uses Trusted Publishing for Visual Studio Marketplace, which we announced recently. If you maintain a Visual Studio extension, especially one already using my publish-marketplace action, this is a small workflow change worth making.
Trust the workflow, not a stored secret
Previously, Start Screen's publishing step received a PAT from a GitHub repository secret. That works, but it leaves a long-lived publishing credential to protect, rotate, and replace when it expires.
With Trusted Publishing, GitHub supplies an OpenID Connect (OIDC) token identifying the workflow. Marketplace checks that identity against a policy configured on my publisher account, then issues a temporary publishing credential that expires after 15 minutes. There is no long-lived Marketplace publishing secret to store in GitHub.
That does not make the workflow immune to compromise. Protecting the repository, reviewing workflow changes, and controlling when releases run still matter. It removes the stored publishing credential rather than removing the need to secure the release process.
First, authorize the workflow in Marketplace
In Marketplace publisher management, open the publisher that owns your extension, select Trusted Publishing, and create a policy. For Start Screen, the identifying values are:
- Repository owner:
madskristensen
- Repository:
StartScreen
- Workflow:
build.yaml, the filename under .github/workflows, not the workflow's display name
- Environment: left empty, because this publishing job does not use a GitHub environment
EditorConfig lives in the EditorConfigLanguage repository. Both repositories have the same GitHub owner and use my MadsKristensen Marketplace publisher, but each needs its own policy. For EditorConfig, the repository is EditorConfigLanguage, the workflow is build.yaml, and the environment is empty. A policy for StartScreen does not authorize the other repository.
Use your own repository and workflow values. If your publishing job uses a GitHub environment, enter its exact name in the policy too. For a private repository, run the workflow within 48 hours of creating the policy; the first successful token exchange permanently activates it.
Also check the publisher property in your existing publish manifest. Start Screen's vs-publish.json uses MadsKristensen. This must identify the Marketplace publisher that owns the policy, not the display name from the VSIX manifest. You do not need to replace the rest of your publishing metadata.
The workflow change was tiny
Start Screen was already using madskristensen/publish-marketplace@v2. Here are the relevant changes from the migration commit:
permissions:
contents: write
+ id-token: write
with:
extension-file: '${{ github.event.repository.name }}.vsix'
publish-manifest-file: 'vs-publish.json'
- personal-access-code: ${{ secrets.VS_PUBLISHER_ACCESS_TOKEN }}
+ oidc: true
The new permission belongs on the publishing job. It allows that job to request a GitHub OIDC token; it does not grant Marketplace access by itself. The Marketplace policy supplies the other half of the authorization.
Start Screen keeps contents: write because the same job also creates a GitHub release. If your job only checks out files and publishes to Marketplace, contents: read is sufficient for those operations.
A publishing job you can adapt
This example assumes your existing build job uploads an artifact named MyExtension.vsix. Keep your own release conditions, artifact names, and paths. Checking out the repository makes the publish manifest, overview, and referenced images available alongside the downloaded VSIX. The action versions match what Start Screen uses today (actions/checkout@v7, actions/download-artifact@v8, paired with actions/upload-artifact@v7 in the build job). Keep the versions you already use if they are older, as long as your upload and download artifact actions are compatible (v4 or later on both sides).
jobs:
publish:
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
needs: build
runs-on: windows-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v7
- uses: actions/download-artifact@v8
with:
name: MyExtension.vsix
- name: Publish to Visual Studio Marketplace
if: github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, '[release]')
uses: madskristensen/publish-marketplace@v2
with:
extension-file: MyExtension.vsix
publish-manifest-file: vs-publish.json
oidc: true
The release condition follows Start Screen's convention: publish on a manual run or a push whose commit message contains [release]. It is an example, not a Trusted Publishing requirement. Keep publishing restricted to your intended release events and branches, and do not run untrusted pull-request code in a publishing job.
The action requires a Windows runner and obtains VsixPublisher.exe from NuGet. You do not need a separate login step. Do not pass personal-access-code alongside oidc: true; the action rejects that combination.
One implementation detail worth knowing
The action currently handles the OIDC exchange itself to work around a missing API-version parameter in the publisher's native exchange. It requests a GitHub token for the Marketplace audience, exchanges it through the versioned Marketplace API, and passes the resulting short-lived credential to VsixPublisher.exe. Despite the tool's argument being named -personalAccessToken, that credential is not a stored PAT. Both tokens are masked, and an authentication failure stops publishing rather than falling back to a PAT.
This is handled inside the action; you do not need to copy token-exchange scripts into your workflow. Use @v2 for updates within the major version, or an immutable release tag such as @v2.2.2. Pinning the action does not pin the BuildTools package it downloads.
Verify the release, then retire the PAT
Keep the old secret available until you have verified your first OIDC publish, but stop passing it to the publishing step. Check that the Marketplace step actually ran and succeeded, then verify the expected version on your listing. A green build with a skipped publishing step is not enough.
For Start Screen, the migration run completed the Marketplace publishing step successfully. The EditorConfig migration run reached Marketplace but failed because the listing had hit its limit of three icon changes in a rolling year. The workflow change is in place, but I still need a successful EditorConfig publish to verify it.
After verifying your own migration, remove the unused repository secret and revoke the old PAT once you have confirmed nothing else relies on it.
If publishing fails, start with the job's id-token: write permission, the policy's repository/workflow/environment values, and the manifest's publisher identifier. The official publishing guide has more detail.
You can inspect the complete workflows for Start Screen and EditorConfig, along with the action's setup instructions, to adapt this to your extension. If you already use the action, the build and packaging process can stay as it is. Configure the trust policy, change the authentication, verify a release, and retire one more long-lived secret.