Search code examples
asp.net-corevisual-studio-2017

Visual Studio 2017 error: Cannot find project info for "" This can indicate a missing project reference


Just installed Visual Studio 2017 (full version) from MSDN website. Created a new Asp.Net Core Web Application (.Net Framework) with .net framework 4.6 selected. Project name = "WebApplicationWithTemplate"

Added another project of type Class Library (.Net Standard) again with .net framework 4.6 selected. Project name = "DataAccessRegular"

Next tried to add the reference of class library project to the Asp.Net Core web application and I get this error:

enter image description here

Cannot find project info for 'E:\Development\VS2017Solution\DataAccessRegular\DataAccessRegular.csproj'. This can indicate a missing project reference. WebApplicationWithTemplate C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets 92

Also created Class Library (.net core) project [not shown in the screen shot above] and added its reference to asp.net core project and still getting the same error.

Also read This link on github but did not find it helpful unfortunately.

The point for asking this is because I want to keep the model, service and data access layers in a separate project.


Solution

  • To solve this, in your csproj for the class library, either change <TargetFramework>netstandard1.4</TargetFramework> to <TargetFramework>net46</TargetFramework> or <TargetFrameworks>netstandard1.4;net46</TargetFrameworks>

    Note, that if you specify more than one target, element should be change to plural TargetFrameworks , not TargetFramework (Build errors when multi-targeting in csproj file)

    What you're seeing is coming from the Class Library (.NET Standard) template actually targeting .NET Standard (netstandard1.4 specifically) rather than the selection in the target framework dropdown. Using the Class Library (.NET Framework) template instead would also work.

    Update:

    Additional options:

    • Change the web application to target .NET Framework 4.6.1 (this will allow things that target netstandard1.4 to be referenced
    • Change the class library to target netstandard1.3 (this will allow it to be referenced from projects targeting .NET Framework 4.6)

    We're also tracking improving the way that these issues get surfaced with https://github.com/dotnet/sdk/issues/829 and https://github.com/dotnet/roslyn-project-system/issues/1470