msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

[Bug]: VS and MSBuild/dotnet build produce behave differently with Build Dependencies

Open msedi opened this issue 1 year ago • 0 comments

Issue Description

VS allows to have build dependencies, that allows to build additional projects next to the main project to ensure satellite projects are also built. This is especially necessary when a project is indirectly dependent on another project. Wheres a project references copy they output of the dependent project to the consuming project, build dependencies just build all dependent projects do not copy the output to the consuming/main projects.

You have to configure the build dependency in the solution.

When building inside Visual Studio this behavior is correct. The projects are build and no dependencies are copied.

When building with MSBuild/dotnet build dependencies are seen as project references, but not completely (only a few components are copied to the consuming project, but not the same way as having a real project reference).

This is especially a problem when people are using VS push their changes to the build agent and get a different behavior. It took us quite a while to find out what the problem really was.

#2274 seems to be related.

Steps to Reproduce

I have attached a demo example to reproduce the behavior.

Dependencies.zip

Expected Behavior

  1. Build Dependencies should be seen as such and not as Project Dependencies
  2. All build tools should behave the same way.

Actual Behavior

  1. Build Dependencies are seen partly as Project Dependencies (MSBuild/dotnet)
  2. Build tools behave differently on different tools

Analysis

I don't know the details, but setting

<AddSyntheticProjectReferencesForSolutionDependencies>false</AddSyntheticProjectReferencesForSolutionDependencies>

seems to solve the problem.

Versions & Configurations

.NET 8 / Visual Studio 2022 17.11 (Preview 2) But it does not seem to a problem of the preview.

msedi avatar Jun 13 '24 07:06 msedi