question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Referenced Projects do not allow referencing via "name" element in project.json

See original GitHub issue

Steps to reproduce

I have a repository with reproducible steps here. You may clone it, perform dotnet restore on /AppLib and then on /App to see the issue.

I have the following directory structure.

Root
  /src
    /App
    /AppLib

AppLib has a simple project.json using a name element to define it’s name as FooLib

{
"name": "FooLib",
"version": "1.0.0",
"authors": [ "scionwest" ],

"dependencies":{
},

"frameworks": {
    "netstandard1.1": {
        "dependencies": {
            "NETStandard.Library": "1.5.0-rc2-24027",
            "System.Linq.Expressions": "4.0.11-rc2-24027"
        }
    }
}
}

It has a single class

namespace AppLib
{
    public class MyClass
    {
    }
}

The App project has a simple project.json as well, referencing the AppLib via it’s folder name.

{
  "version": "1.0.0",
  "buildOptions": {
    "emitEntryPoint": true
  },
  "dependencies": {
    "AppLib": "1.0.0",
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.0-rc2-3002702"
    }
  },
  "frameworks": {
    "netcoreapp1.0": {
      "imports": "dnxcore50"
    }
  }
}

It has the basic Program.cs class

using System;
using AppLib;

namespace ConsoleApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var c = new MyClass();
            Console.WriteLine("Hello World!");
        }
    }
}

Run dotnet restore on both projects, then run dotnet run to see this work correctly.

Next, modify the /App/project.json to reference FooLib instead of AppLib, then dotnet restore the App project to generate the error.

Expected behavior

The App project should be able to reference the AppLib via its name defined in project.json instead of the folder name.

Actual behavior

Unable to resolve ‘FooLib (>= 1.0.0)’ for ‘.NETCoreApp,Version=v1.0’.

Environment data

.NET Command Line Tools (1.0.0-preview1-002702)

Product Information: Version: 1.0.0-preview1-002702 Commit Sha: 6cde21225e

Runtime Environment: OS Name: Mac OS X OS Version: 10.11 OS Platform: Darwin RID: osx.10.11-x64

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
scionwestcommented, May 22, 2016

I’m not renaming a project though, are you saying that the folder name is the project name? If so, what is the point of the name element in the project.json?

0reactions
TheRealPiotrPcommented, May 26, 2016

We’ll track this in dotnet/sdk#5868

Read more comments on GitHub >

github_iconTop Results From Across the Web

Net Core project.json multiple projects with the same name
The only solution is to rename the packages. It's almost like having two types with the same name, both imported and referencing them...
Read more >
Reference local projects in Source Generator #47517
How do I reference a local project from a Source Generator project. The project is also used from normal .Net projects so cannot...
Read more >
PackageReference in project files - NuGet
This will enable packages that those projects refer to, to be "transitively" referenced by your project.
Read more >
Project References - TypeScript: Documentation
Project references are a new feature in TypeScript 3.0 that allow you to structure your TypeScript programs into smaller pieces. By doing this,...
Read more >
MSBuild reference for .NET SDK projects
This page is a reference for the MSBuild properties and items that you can use to configure .NET projects. Note. This page is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found