Skip to content

"error NETSDK1007: Cannot find project info" when a csproj with a certain name depends on another in the same directory. #2779

@livarcocc

Description

@livarcocc

From @davedissian on December 29, 2018 14:42

If I have two csproj's within the same directory, where csproj (1) depends on csproj (2), I get a NETSDK1007 error if the dependency (2) has a name which is lexicographically greater than the root project (1). For example, if I have Worker.csproj which depends on Library.csproj, it compiles fine. However, If I have AWorker.csproj which depends on Library.csproj, I get an NETSDK1007 error.

I guess the cause might have something to do with dependency resolution only being a single pass process (rather than being a two pass process that stores projects in a lookup table before resolving them).

Steps to reproduce

I have attached a zip file with 3 solutions: NETSDK1007-issue.zip

  • Broken - A solution containing projects AWorker.csproj and Library.csproj
  • Working - A solution containing projects Worker.csproj and Library.csproj
  • WorkingSeparateDir - A solution containing projects AWorker.csproj and Library\Library.csproj

If I try and run dotnet build Worker.sln inside Broken, I get the following output:

Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restoring packages for /Users/david/Projects/DotnetCsharpBug/Broken/AWorker.csproj...
  Generating MSBuild file /Users/david/Projects/DotnetCsharpBug/Broken/obj/AWorker.csproj.nuget.g.props.
  Generating MSBuild file /Users/david/Projects/DotnetCsharpBug/Broken/obj/AWorker.csproj.nuget.g.targets.
  Restore completed in 244.37 ms for /Users/david/Projects/DotnetCsharpBug/Broken/AWorker.csproj.
/usr/local/share/dotnet/sdk/2.2.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(129,5): error NETSDK1007: Cannot find project info for '/Users/david/Projects/DotnetCsharpBug/Broken/Library.csproj'. This can indicate a missing project reference. [/Users/david/Projects/DotnetCsharpBug/Broken/Library.csproj]

Build FAILED.

/usr/local/share/dotnet/sdk/2.2.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(129,5): error NETSDK1007: Cannot find project info for '/Users/david/Projects/DotnetCsharpBug/Broken/Library.csproj'. This can indicate a missing project reference. [/Users/david/Projects/DotnetCsharpBug/Broken/Library.csproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.23

The project files look like this:

AWorker.csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="Library.csproj" />
    <Compile Include="Class1.cs" />
  </ItemGroup>

</Project>

Library.csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="Library\Class1.cs" />
  </ItemGroup>

</Project>

Expected behavior

It compiles successfully.

Environment data

$ dotnet msbuild -version
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

15.9.20.62856

OS info:
macOS Mojave 10.14.2

If applicable, version of the tool that invokes MSBuild (Visual Studio, dotnet CLI, etc):

$ dotnet --version
2.2.100

Copied from original issue: dotnet/msbuild#4035

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions