Hosting VSIX feed as AppVeyor artifact

We have a GitHub repository with Visual Studio extensions. We are using AppVeyor as CI tool. We produce VSIX artifacts on AppVeyor. We wanted a feed to easily install these artifacts.

One of the motivations behing this post is Mads Kristensen's tool for generating private feeds.

First of all, we need to update all VSIX manifests to match current CI build version.

Add a script to be executed before build.

- ps: .\tools\AppVeyor-BeforeBuild.ps1






function Vsix-SetVersion 
    param([string] $version = $env:APPVEYOR_BUILD_NUMBER)

    if (-not($version)) 
        Throw "Parameter -Version is required";

    $targetVersion = "0.0.$version";

    Push-Location $PSScriptRoot;

    Write-Host "Updating manifests to version '$targetVersion'.";

    $manifestFiles = Get-ChildItem -Path ..\ -Filter *.vsixmanifest -Recurse -File -Name;
    foreach ($manifestFile in $manifestFiles) 
        $manifestFile = Resolve-Path -Path "..\$manifestFile";
        Write-Host "Updating manifest $manifestFile";

        [xml]$manifestXml = Get-Content $manifestFile

        $ns = New-Object System.Xml.XmlNamespaceManager $manifestXml.NameTable
        $ns.AddNamespace("ns", $manifestXml.DocumentElement.NamespaceURI) | Out-Null

        $attrVersion = ""

        if ($manifestXml.SelectSingleNode("//ns:Identity", $ns))
            $attrVersion = $manifestXml.SelectSingleNode("//ns:Identity", $ns).Attributes["Version"]
            $attrVersion.InnerText = $targetVersion
            $manifestXml.Save($manifestFile) | Out-Null


It iterates over all *.vsixmanifest files, loads content as XML and updates attribute Version of element Identity.

Now we can run msbuild and produce CI builds of correct version. Next step is to grab all VSIX and push them as AppVeyor artifacts.

Add a post build action after_build to the appveyor.yml.

- ps: .\tools\AppVeyor-PushArtifacts.ps1

The AppVeyor-PushArtifacts.ps1 included later uses a VSIX feed template file.


<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="" xmlns:xsi="">
  <title type="text" />
    <title type="text">{Name}</title>
    <summary type="text" xsi:nil="true" />
    <content type="application/octet-stream" src="{JobId}/artifacts/{FileName}" />
    <Vsix xmlns="" xmlns:xsd="">

It uses {...} tokens to be replaced by actual values. The entry element is a template that is used for each VSIX file.

The publish script is quite long, but not so complicated. It finds the entry template element in XML, iterates over *.vsix files and appends updated entry element to the document. Finally it pushes Feed.xml as AppVeyor artifact.


param([string] $version = $env:APPVEYOR_BUILD_NUMBER, [string] $jobId = $env:APPVEYOR_JOB_ID)

if (-not($version)) 
    Throw "Parameter -Version is required";

if (-not($jobId)) 
    Throw "Parameter -JobId is required";

Push-Location $PSScriptRoot;
. ".\Vsix-GetId.ps1";

# Feed file paths.
$templatePath = Resolve-Path -Path "..\NightlyFeedTemplate.xml";
$outputPath = "..\NightlyFeed.xml";
Set-Content $outputPath "";
$outputPath = Resolve-Path -Path $outputPath;

$targetVersion = "0.0.$version";

$timestamp = Get-Date -Format o;
[xml]$xml = Get-Content $templatePath;

# XML namespaces.
$atomNs = New-Object System.Xml.XmlNamespaceManager $xml.NameTable;
$atomNs.AddNamespace("ns", "") | Out-Null;
$vsixNs = New-Object System.Xml.XmlNamespaceManager $xml.NameTable;
$vsixNs.AddNamespace("vsix", "") | Out-Null;

$xml.SelectSingleNode("//ns:updated", $atomNs).InnerText = $timestamp;

# Find entry template element and remove it from XML document.
# We need only for cloning, it shouldn't in the result feed.
$entryXml = $xml.SelectSingleNode("//ns:entry", $atomNs);
$xml.DocumentElement.RemoveChild($entryXml) | Out-Null;

foreach ($artifact in (Get-ChildItem ..\*.vsix -Recurse)) 
    # Publish VSIX as artifact.
    $artifactFileName = "$($artifact.BaseName)-v$($targetVersion)$($artifact.Extension)";
    Push-AppveyorArtifact $artifact.FullName -FileName $artifactFileName;

    # Find VSIX id in manifest file.
    $projectDirectory = $artifact.Directory.Parent.Parent;
    $manifestPath = Join-Path $projectDirectory.FullName "source.extension.vsixmanifest";
    $id = Vsix-GetId -Manifest $manifestPath;

    # Clone entry element.
    $artifactXml = $entryXml.Clone();

    # Modify entry XML.
    $artifactXml.SelectSingleNode("//ns:id", $atomNs).InnerText = $id;
    $artifactXml.SelectSingleNode("//ns:title", $atomNs).InnerText = $artifact.BaseName;
    $artifactXml.SelectSingleNode("//ns:published", $atomNs).InnerText = $timestamp;
    $artifactXml.SelectSingleNode("//ns:updated", $atomNs).InnerText = $timestamp;
    $url = $artifactXml.SelectSingleNode("//ns:content", $atomNs).Attributes["src"].Value;
    $url = $url.Replace("{FileName}", $artifactFileName);
    $url = $url.Replace("{JobId}", $jobId);
    $artifactXml.SelectSingleNode("//ns:content", $atomNs).Attributes["src"].Value = $url;
    $artifactXml.SelectSingleNode("//vsix:Id", $vsixNs).InnerText = $id;
    $artifactXml.SelectSingleNode("//vsix:Version", $vsixNs).InnerText = $targetVersion;

    # Append entry to the XML document.
    $xml.DocumentElement.AppendChild($artifactXml) | Out-Null;

# Save and publish Feed.xml as artifact.
Push-AppveyorArtifact $outputPath -FileName "Feed.xml";



Now you can grab Feed.xml and map it as a VSIX feed in Visual Studio.

Visual Studio extension feed settings


Posted on 2019-06-25
Written by Maraf