Project-system: How can I disable transitive project reference in new csproj format?

Created on 29 May 2017  路  1Comment  路  Source: dotnet/project-system

Repro steps

Version used: Visual Studio 2017 (15.2 (26430.6)) Release

Create projects as follows:

image

Sample Projects: NewCsproj.zip

Expected behavior

Successfully compiled and show "BBBB".

Actual behavior

Compilation error:

5>C:\Program Files\dotnet\sdk\2.0.0-preview1-005977\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(94,5): error : Cannot find project info for 'c:\users\***\documents\visual studio 2017\Projects\NewCsprojWeb\ClassLibraryA\ClassLibraryA.csproj'. This can indicate a missing project reference.

Most helpful comment

In your ClassLibraryDependingOnA, you can add PrivateAssets=All to the ProjectReference to ClassLibraryA like this:

  <ItemGroup>
    <ProjectReference Include="..\ClassLibraryA\ClassLibraryA.csproj" PrivateAssets="All" />
  </ItemGroup>

This will stop the flow of ClassLibraryA further up the graph.

>All comments

In your ClassLibraryDependingOnA, you can add PrivateAssets=All to the ProjectReference to ClassLibraryA like this:

  <ItemGroup>
    <ProjectReference Include="..\ClassLibraryA\ClassLibraryA.csproj" PrivateAssets="All" />
  </ItemGroup>

This will stop the flow of ClassLibraryA further up the graph.

Was this page helpful?
0 / 5 - 0 ratings