0

Nuget depends on this singular file, to be in the same directory as the project. This means if there are two projects in one directory, they will conflict.

How can I make nuget stop relying on this horrible file?

Sanket
  • 19,295
  • 10
  • 71
  • 82
Jarryd
  • 572
  • 4
  • 13

1 Answers1

1

Ideally, 2 projects should be in 2 different folders.

For example, I have ASP.NET Core application (based on project.json) and class library (based on project.json) then my folder structure looks like this-

Solution Level Folder (Here you will .sln file and below src folder)

src folder

  • ASP.NET Core application folder (Here you will have main project.json)

  • Class Library folder (Here you will have class library project.json)

This way, it will not affect each other.


Other option is to rename project.json to {project-name}.project.json

This prevents potential conflict in Visual Studio when trying to restore packages for the libraries in the same directory.

For more information on this, refer NuGet FAQ-

I have multiple projects in the same folder, how can I use separate packages.config or project.json files for each project?

In most projects where separate projects live in separate folders, this is not a problem as NuGet will identify the packages.config and project.json files in each project. With NuGet 3.3+ and multiple projects in the same folder, you can insert the name of the project into the packages.config or project.json filenames as below and NuGet will use that file:

packages.config: use the pattern packages.{project-name}.config

project.json: use the pattern {project-name}.project.json

Sanket
  • 19,295
  • 10
  • 71
  • 82
  • Not acceptable. This is a multi-platform game, where code is shared between two different projects, one representing UWP and the other Desktop (Steam vs Windows store). – Jarryd Mar 02 '17 at 10:03
  • In my solution, I renamed several **project.json** files to be named **[UWP] Hazzah Engine.project.json**, and **[UWP] Block Game.project.json** (two examples), And this solved the issue. Thank you. – Jarryd Mar 02 '17 at 10:33