I have a .NET Solution which contains a project of type classlib. At the end of the day, I want to deploy this package to a private NuGet feed. However, I am still in the early stages and I just want to use a local NuGet feed for development. I have a second solution that uses/ references the classlib. BTW, I am using VS Code and the dotnet CLI.
My workflow so far:
Pack the classlib into a NuGet-Package (.nupkg).
$ dotnet pack
Automatically copy the package to my local NuGet feed.
<Target Name="CopyPackage" AfterTargets="Pack">
<Copy SourceFiles="./bin/Debug/$(PackageId).$(PackageVersion).nupkg" DestinationFolder="path/to/local/nuget/packages" />
</Target>
Add package to my concrete solution.
dotnet add package <package-name>
So far, this works. However, after making changes in the classlib and using dotnet pack I override my existing package cause I do not want to specify a new Version as it still is 1.0.0. Even after removing and adding the package to my concrete solution and rebuilding it, the changes are still not available. How can I make this work without updating the version? Must be a caching issue. How can I improve this workflow?
I know that having both Projects in the same solution would make testing easier, but I want to separate them from the start for several reasons.
When you add the nuget reference to your classlib, it will be installed in your local global-packages cache. Your other project which references the classlib via nuget will be referencing the local cached version. To fix your local development workflow the cached version will need to be deleted, so your newer 1.0.0 version will be copied from your local package repository to the local cache.
My global package cache is located at C:\Users\<MyUsername>\.nuget\packages
Use can use the following to list all the nuget caches on your machine.
dotnet nuget locals all -l
Delete the specific version from the package cache.
del C:\Users\<MyUsername>\.nuget\packages\classlib\1.0.0\ -force -rec
Restore your packages and you're good to go!