Skip to content

Conflict in publish between file from Microsoft.NET.Build.Extensions and NuGet package #3904

@dsplaisted

Description

@dsplaisted

With the following project:

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

  <PropertyGroup>
    <TargetFramework>net461</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore" Version="2.1.4" />
    <PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" />
  </ItemGroup>
</Project>
  • Make sure to delete the output folder
  • Publish the project and generate a .binlog (dotnet publish -bl)
  • Open .binlog in MSBuild structured log viewer

Expected: No DoubleWrites reported

Actual: DoubleWrites reported for System.Runtime.InteropServices.RuntimeInformation.dll

The file is being copied to the publish folder from the following two locations:

  • C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.runtime.interopservices.runtimeinformation\4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll
  • C:\Program Files\dotnet\sdk\3.1.100-preview3-014645\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Runtime.InteropServices.RuntimeInformation.dll

On publishing the second time, the DoubleWrite will likely not be reported, as the output will be considered up to date in the _CopyResolvedFilesToPublishPreserveNewest target.

I am not sure exactly what determines which of the files wins. However, if the wrong file is copied (and we have a customer report where this happened), then the app will fail at runtime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions