3
votes

My .NET Core project references a class library from another project.

I publish the nuget package to a local folder like this:

"scripts": {
  "postcompile": [
    "dotnet pack --no-build --configuration %compile:Configuration% -o D:\\mynugetpackages\\%project:Name%"
  ]
}

Then I add a reference to another project from this folder.

Every time I update my class library, I have to manually go to manage nuget packages and then update nuget packages from Visual Studio in the referencing project.

Is there a way to automate this, so that when I make an update and publish latest nuget package, the referencing project will automatically update to the latest update?

1

1 Answers

1
votes

No, it's not possible for Visual Studio to automatically detect that a package has been updated (in a local or remote source).

You could write a script to run nuget update in your target project to grab the latest packages, but you'd still likely have to kick off the script manually. This would at least be faster than manually clicking through the NuGet GUI in Visual Studio.

Another option is to put the class library in the same solution folder structure as your main project, and reference it as a project dependency:

"dependencies": {
  "MyClassLib": {
    "target": "project"
  }
}

This only works if you're able to adopt this folder structure, though:

src/
  MyProject/
  MyClassLib/