Disable import sugesstions for cross-project imports / prevent cross-project dependencies

I have one solution with multiple projects which are complete separately built and should not use cross-project classes and other dependencies. I merged the originally separate projects into one solution, to have all code which belongs to one software project in one place.

However, is there a way to prevent that Project A uses any dependencies of Project B? Especially also disabling that import suggestions are made for Project B while I'm working on Project A files?

0
1 comment

Hello, Ssedighi ,

I assume that projects in your solution reference each other and you're seeing completion suggestions for dependencies of Project A when typing in project B because of a transitive dependency.

Please consider editing project references in your project files this way: add <ExcludeAssets>compile</ExcludeAssets> property to the reference declaration.

E.g.:

<ItemGroup>
      <ProjectReference Include="..\ProjectA\ProjectA.csproj">
          <ExcludeAssets>compile</ExcludeAssets>
      </ProjectReference>
  </ItemGroup>

Here's the relevant part of Microsoft documentation on this.

0

Please sign in to leave a comment.