Search code examples
.netnuget.net-core.net-core-rc2project.json

.NET Core RC2: use local fork of a package


I have a project which in turn references a fork of an official nuget'd library (forecast.io). I've arranged my global.json to find my copy of the lib, yet a dotnet restore still seems to reach out to the official version rather than my fork.

I form this conclusion because I get the error:

Package Forecast.io 1.0.0 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Forecast.io 1.0.0 supports: net45 (.NETFramework,Version=v4.5)
One or more packages are incompatible with .NETCoreApp,Version=v1.0.

Yet my fork of forecast.io doesn't even target .NET 4.5 - only "net40" and "netcoreapp1.0".

How can I ensure that my local fork is used instead?

Here's my global.json

{
  "projects": [
    "../../ext/forecast.io-csharp/src/Forecast.io",
    "MyOtherLibRefWhichWorks",
    "MyPrimaryProject"
  ]
}

And a snippet from project.json from primary project:

  "dependencies": {
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.0-rc2-3002702"
    },
    "MyOtherLibRefWhichWorks": "1.0.0-*",
    "Forecast.io": "1.0.0-*",

EDIT: It seems like global.json goes completely ignored. It's located one directory above where the project.json is located..


Solution

  • Creating your own local or remote Nuget feed will be a much more reliable solution for this situation. I do this myself for managing beta versions of packages I publish and it works really well.

    To do it locally, you just need an empty folder and the Nuget CLI. If your folder is C:\Nuget, run

    nuget add package.nupkg -source C:\Nuget
    

    To add your forked package to the local feed. To make sure there isn't any confusion, build your forked package with either a different name or version number than the official package.

    Then, configure Nuget to use your local feed as a source:

    nuget sources Add -Name LocalNuget -Source C:\Nuget
    

    Once this is all set up, update your project.json to reference your forked package and run dotnet restore again to pull down the local copy.

    If you need to restore the package on multiple machines, or in a team environment, you can set up your own NuGet server or use MyGet.org to host your package.