Skip to content

inconsistent/diverging build outcome from API and dotnet build, msbuild, VS #49874

Closed
@ltcmelo

Description

@ltcmelo

Version Used: 3.8.0

Steps to Reproduce:

Consider proj.sln with libX.csproj and libY.csproj, and with libY.csproj referencing libX as follows — in
a supposedly bogus .csproj, given that libX is referenced both as a project and as a binary/assembly.

# libY.csproj file
    …
    <ProjectReference Include="..\libX\libX.csproj" />
    …
    <Reference Include="libX">
      <HintPath>..\path\to\assembly\libX.dll</HintPath>
    </Reference>
    …

Despite the duplicity of references to libX from libY.csproj, building the solution proj.sln is successful in all of:

  • dotnet build
  • msbuild
  • inside VS

However, if I have 2 Microsoft.CodeAnalysis.Project objects that mirror the setup I described above — with corresponding ProjectReference and MetadataReferences in "projLibY" for "projLibX" — and attempt to build them, I get a compilation error such as:

error CS1704: An assembly with the same simple name 'libX' has already been imported. Try removing one of the references …

While I'd acknowledge that the csproj file in question isn't really correct, for the sake of consistency with the other building mechanisms (which silently handle the duplication), I'd consider this behavior of the API a bug.

NOTE: In order to reproduce the issue, one might need to ensure that libX.dll is a different binary from that produced by the current build of libX.csproj.

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions