.netvisual-studio-2015vcxproj

How to make local nuget packages and reference them across solutions locally in dotnet core


We have many libraries that are split across different solutions (separation of concerns). On each check in new nuget packages are build and the solutions depending on these other packages can updates their references.

In an ideal world, everything should be unit tested, CI tested of cause, but real life hits and at some point some corner case bug surfaces that is hard to reproduce and some local debugging is needed.

To avoid doing what we properly all have tried on some small project at some point, checking in N times with small fixes that turns out to not be the fix :) and get a new build is pain and time consuming.

Before dotnet core I used to debug these by in the referencing solutions just add a local reference to the locally build dll and fix the issue before committing. With dotnet core this has turned out to not be possible due to everything needs to be wrapped in a nupkg.

I need a simple workflow/process for handling these cases in dotnet core also?


Solution

  • This is the result of what I came up with, maybe someone have a better way.

    https://twitter.com/pksorensen/status/761590754301079552 https://gist.github.com/pksorensen/df61ded634bad99f85cc68f91c230361

    "scripts": {
        "postcompile": [
          "nuget delete -Verbosity detailed -noninteractive -source %USERPROFILE%\\.nuget\\packages %project:name% %project:version%",
          "nuget delete -Verbosity detailed -noninteractive -source c:\\localpackages %project:name% %project:version%",
          "dotnet pack --no-build --configuration %compile:Configuration% -o ../../artifacts/",
          "nuget add -Verbosity detailed -NonInteractive -source c:\\localpackages  ../../artifacts/%project:name%.%project:version%.nupkg"
        ]
      }
    

    Using local feeds I added a feed according to : https://docs.nuget.org/create/hosting-your-own-nuget-feeds at c:\localpackages.

    1. Then on each build I pack and push the package to this local source
    2. To do so i also must delete the same version if its already there (one of the delete).
    3. Due to nuget also caches packages in the user folder global folder, it must also be deleted there.

    When the build completes, i simply can right click and restore packages in the solutions that depends on these local packages.

    When the issue is fixed, its simply to commit both solutions to the CI system again and it will resolve packages from the normal feed rather than the local feed that is only available on my dev machine.