.netvisual-studio-codenugetpackagedotnet-restore

How to persuade VS Code to refer to the latest version of a package?


We're using a private NuGet feed to manage a couple of dependencies.

After updating a dependency (e.g. adding a property to a class) and triggering build and release, I can see that dotnet restore downloads the new version:

$ dotnet restore
  Restoring packages for C:\Users\me\blah\whatever.csproj...
  Installing My.Package 1.0.NewVersion.
  Restore completed in 63.97 ms for C:\Users\me\blah\whatever.csproj.
  Generating MSBuild file C:\Users\me\blah\whatever.csproj.nuget.g.props.

But when I try to access the new property I get red squiggles. When I F12 to view the metadata of the class in question, sure enough, my property is absent.

If I nuke the NuGet cache and restore again, I'm able to get the new version. This feels like a nuclear option - is there a subtler way?


Quick update... The reference to the package in the csproj file looks like this:

<PackageReference Include="My.Package" Version="0.0.*" />

With the intention that it'll always refer to the latest patch version.


Solution

  • The way I've found to do this reliably is a bit of a sledgehammer...

    Step 1: Nuke nuget with dotnet nuget locals all -clear

    Step 2: Restart Omnisharp using the command palette.