Skip to content

On VS2019, NuGet is eager to update my packages and ends up corrupting my versions #429

@astrohart

Description

@astrohart

When I create a new VSIX Community package on VS2019, versions of the extensibility NuGet packages Community.VisualStudio.Toolkit.16 and friends are installed that are compatible with Visual Studio 2019.

However, Microsoft.VSSDK.BuildTools is also installed, and its versions go into 17+. Along the way of creating a recent package project generated by this extension, I got build errors basically because I am trying to use version 17+ of Microsoft.VSSDK.BuildTools with VS2019 when I speculate that v17+ of Microsoft.VSSDK.BuildTools is only compatible with VS2022.

The NuGet infrastructure in VS2019 is very conscientious about making sure I have the correct and updated NuGet packages at all times. And then the project won't build for the reason cited above and it produces really cryptic build errors that took several hours and lots of Googling to hunt down.

To fix this, modify the PackageReference lines in the project file to be thus:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <!-- *** -->
  <ItemGroup>
    <PackageReference Include="Community.VisualStudio.Toolkit.16" Version="16.0.492" ExcludeAssets="Runtime">
      <IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Community.VisualStudio.VSCT" Version="[16.0.29.6, 16.0.29.6]" PrivateAssets="all" />
    <PackageReference Include="Microsoft.VSSDK.BuildTools" Version="[16.10.1055, 16.11.69]" />
  </ItemGroup>
  <!-- *** -->
</Project>

@madskristensen I highly suggest you modify the code of the extension so that it generates the proper package refs. This way I do not have to make this fix each and every time I generate a new extension package project.

I'll be glad to submit a PR.

SCRATCH THAT

I can't submit a PR because I have no clue how this extension actually generates the projects with Visual Studio, as I cloned the forked repo (forked it to my GitHub account first, then cloned it locally) and I could not see a .vstemplate file anywhere.

@madskristensen would you mind terribly updating the code so I get the PackageReferences shown for new projects? Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions