sdk: System.Drawing.Common.dll is not added to Net Core build output

From @Persimus on Friday, April 24, 2020 9:37:23 AM

Steps to reproduce

Create an application for .Net Core add System.Drawing.Common Nuget or Direct dll reference, and build. You will see that the dll is not in the output directory.

This issue causes runtime errors in Linux containers if you run Build and Publish processes on Windows machine or TFS server and then try to run them on Linux container. When processes that needs dll to run is called exception is thrown: “System.IO.FileNotFoundException: Could not load file or assembly ‘System.Drawing.Common’”, otherwise no build or deploy issues were observed.

Issue observed after updating From: Microsoft ® Build Engine version 16.4.0+e901037fe for .NET Core To: Microsoft ® Build Engine version 16.5.0+d4cbfca49 for .NET Core

Project file

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

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="System.Drawing.Common" Version="4.7.0" />
  </ItemGroup>

</Project>

Expected behavior

System.Drawing.Common.dll is in output directory

Actual behavior

System.Drawing.Common.dll is not added

OS info: Windows 10, TFS server

If applicable, version of the tool that invokes MSBuild (Visual Studio, dotnet CLI, etc): Build Engine version 16.5.0+d4cbfca49 for .NET Core

Copied from original issue: microsoft/msbuild#5312

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 1
  • Comments: 22 (15 by maintainers)

Most upvoted comments

I’m experiencing a similar issue targeting net8.0-windows in my Unit Testing project. The same does not happen with net6 and net7. Could be a related issue of this?

I’m using Visual Studio Version 17.8.3.

image

Attached you can find the project to reproduce the issue. Just unzip, open the solution, and rebuild it with Visual Studio 2022.

UnitTesting-Net8-System.Drawing.Common-Issue.zip

@dsplaisted Repro solution attached below. WebApplication.zip

There are 2 Web projects: with runtime specified and without. Specifying runtime seems to help the newer MSBuild to copy System.Drawing.Common dependencies.

When runtime is not specified, newer version of MSBuild does not copy all dependencies (see files list below).

Publishing done in PostBuild Event.

Output for WebApplicationNoRuntime using MSBuild 16.4.0+901037fe for .NET Core (runtimes folder contains System.Drawing.Common and its dependencies): image

Output for WebApplicationNoRuntime using MSBuild 16.8.3+39993bd9d for .NET: image