Porting my Visual Studio Parameters.xml Generator tool to Visual Studio 2022 Preview

As I am sure you are all aware the preview of Visual Studio 2022 has just dropped, so it is time for me to update my Parameter.xml Generator Tool to support this new version of Visual Studio.

But what does my extension do?

As the Marketplace description says...

A tool to generate parameters.xml files for MSdeploy from the existing web.config file or from an app.config file for use with your own bespoke configuration transformation system.

Once the VSIX package is installed, to use right-click on a web.config, or app.config, file in Solution Explorer and the parameters.xml file will be generated using the current web.config entries from for both configuration/applicationSettings and configuration/AppSettings. The values attributes will contain TAG style entries suitable for replacement at deployment time.

I_f the parameters.xml already exists in the folder (even if it is not a file in the project) you will be prompted before it is overwritten._

Currently the version in the Marketplace of Parameter.xml Generator Tool supports Visual Studio 2015, 2017 & 2019

Adding Visual Studio 2022 Support

The process to add 2022 support is more complicated than adding past new versions, where all that was usually required was an update to the manifest. This is due to the move to 64Bit.

Luckily the process is fairly well documented, but of course I still had a few problems.

MSB4062: The "CompareBuildTaskVersion" task could not be loaded from the assembly

When I tried build the existing solution, without any changes, in Visual Studio 2022 I got the error

MSB4062: The "CompareBuildTaskVersion" task could not be loaded from the assembly D:myprojectpackagesMicrosoft.VSSDK.BuildTools.15.8.3253toolsVSSDKMicrosoft.VisualStudio.Sdk.BuildTasks.15.0.dll. Could not load file or assembly.

This was fixed by updating the package Microsoft.VSSDK.BuildTools from 15.1.192 to 16.9.1050.

Modernizing the Existing VSIX project

I did not modernize the existing VSIX project before I started the migration. When I clicked the Migrate packages.config to PackageReference…. it said my project was not a suitable version. So I just moved to the next step.

After creating the shared code project, that contains the bulk of the files, I needed to add links to some of the resources i.e. the license file, the package icon and .VSCT file.

When I tried add the link, I got an error in the form

_ Cannot add another link for the same file in another project_

I tried exiting Visual Studio, cleaning the solution, nothing helped. The solution was to edit the .CSPROJ file manually in a text editor e.g.

 1 <ItemGroup>
 2    <Content Include="ResourcesLicense.txt">
 3      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
 4    <Content Include="..ParametersXmlAddinSharedResourcesPackage.ico">
 5      <Link>Package.ico</Link>
 6      <IncludeInVSIX>true</IncludeInVSIX>
 7    </Content>
 8    <Content Include="ResourcesPackage.ico">
 9      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
10    <Content Include="..ParametersXmlAddinSharedResourcesLicense.txt">
11      <Link>License.txt</Link>
12      <IncludeInVSIX>true</IncludeInVSIX>
13    </Content>
14    <EmbeddedResource Include="ResourcesParametersUppercaseTransform.xslt" />
15    <VSCTCompile Include="..ParametersXmlAddinSharedParametersXmlAddin.vsct">
16      <Link>ParametersXmlAddin.vsct</Link>
17      <ResourceName>Menus.ctmenu</ResourceName>
18    </VSCTCompile>
19  </ItemGroup>

Publishing the new Extension

Once I had completed the migration steps, I had a pair of VSIX files. The previously existing one that supported Visual Studio 2015, 2017 & 2019 and the new Visual Studio 2022 version.

The migration notes say that in the future we will be able to upload both VSIX files to a single Marketplace entry and the Marketplace will sort out delivering the correct version.

Unfortunately, that feature is not available at present. So for now the new Visual Studio 2022 VSIX is published separately from the old one with a preview flag.

As soon as I can, I will merge the new VSIX into the old Marketpalce entry and removed the preview 2022 version of the VSIX