Skip to content

System.CodeDom.dll is copied to the output/build directory when referencing System.Management v8 #4152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
EatonZ opened this issue Feb 10, 2024 · 8 comments

Comments

@EatonZ
Copy link

EatonZ commented Feb 10, 2024

Describe the bug

There appears to be an issue in .NET 8's System.Management package that unnecessarily copies System.CodeDom.dll to the output/build directory. This does not occur in .NET 7 / System.Management v7.

To Reproduce

  1. Create a new .NET 8 WinForms project in Visual Studio.
  2. Add the latest stable System.Management package via NuGet.
  3. Build the project and you will find that System.CodeDom.dll exists: \bin\Debug\net8.0-windows\System.CodeDom.dll

Now, if you go into your NuGet packages and downgrade System.Management from v8.0.0 to v7.0.2, rebuild the project, you will find that System.CodeDom.dll is no longer copied. The issue seems exclusive to the .NET 8 version of System.Management.

Further technical details

Visual Studio 2022 64-bit, version 17.8.6

dotnet --info

.NET SDK:
 Version:           8.0.101
 Commit:            6eceda187b
 Workload version:  8.0.100-manifests.30fce108

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22631
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\8.0.101\

.NET workloads installed:
 Workload version: 8.0.100-manifests.30fce108
There are no installed workloads to display.

Host:
  Version:      8.0.1
  Architecture: x64
  Commit:       bf5e279d92

.NET SDKs installed:
  8.0.101 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@KalleOlaviNiemitalo
Copy link

When the project targets net7.0-windows and references System.Management 7.0.2, .NET SDK does not copy System.CodeDom.dll to the output directory;

Encountered conflict between 'Reference:[REDACTED]\.nuget\packages\system.codedom\7.0.0\lib\net7.0\System.CodeDom.dll' and 'Reference:[REDACTED]\.nuget\packages\microsoft.windowsdesktop.app.ref\7.0.15\ref/net7.0/System.CodeDom.dll'. Choosing 'Reference:[REDACTED]\.nuget\packages\microsoft.windowsdesktop.app.ref\7.0.15\ref/net7.0/System.CodeDom.dll' because file version '7.0.1523.57226' is greater than '7.0.22.51805'.

Encountered conflict between 'Platform:System.CodeDom.dll' and 'CopyLocal:[REDACTED]\.nuget\packages\system.codedom\7.0.0\lib\net7.0\System.CodeDom.dll'. Choosing 'Platform:System.CodeDom.dll' because it comes from a package that is preferred.

When the project targets net8.0-windows and references System.Management 7.0.2, .NET SDK does not copy System.CodeDom.dll to the output directory;

Encountered conflict between 'Reference:[REDACTED]\.nuget\packages\system.codedom\7.0.0\lib\net7.0\System.CodeDom.dll' and 'Reference:C:\Program Files\dotnet\packs\Microsoft.WindowsDesktop.App.Ref\8.0.1\ref/net8.0/System.CodeDom.dll'. Choosing 'Reference:C:\Program Files\dotnet\packs\Microsoft.WindowsDesktop.App.Ref\8.0.1\ref/net8.0/System.CodeDom.dll' because AssemblyVersion '8.0.0.0' is greater than '7.0.0.0'.

Encountered conflict between 'Platform:System.CodeDom.dll' and 'CopyLocal:[REDACTED]\.nuget\packages\system.codedom\7.0.0\lib\net7.0\System.CodeDom.dll'. Choosing 'Platform:System.CodeDom.dll' because AssemblyVersion '8.0.0.0' is greater than '7.0.0.0'.

When the project targets net7.0-windows and references System.Management 8.0.0, .NET SDK copies System.CodeDom.dll to the output directory:

Encountered conflict between 'Reference:[REDACTED]\.nuget\packages\system.codedom\8.0.0\lib\net7.0\System.CodeDom.dll' and 'Reference:[REDACTED]\.nuget\packages\microsoft.windowsdesktop.app.ref\7.0.15\ref/net7.0/System.CodeDom.dll'. Choosing 'Reference:[REDACTED]\.nuget\packages\system.codedom\8.0.0\lib\net7.0\System.CodeDom.dll' because AssemblyVersion '8.0.0.0' is greater than '7.0.0.0'.

Encountered conflict between 'Platform:System.CodeDom.dll' and 'CopyLocal:[REDACTED]\.nuget\packages\system.codedom\8.0.0\lib\net7.0\System.CodeDom.dll'. Choosing 'CopyLocal:[REDACTED]\.nuget\packages\system.codedom\8.0.0\lib\net7.0\System.CodeDom.dll' because AssemblyVersion '8.0.0.0' is greater than '7.0.0.0'.

When the project targets net8.0-windows and references System.Management 8.0.0, .NET SDK copies System.CodeDom.dll to the output directory:

Encountered conflict between 'Reference:[REDACTED]\.nuget\packages\system.codedom\8.0.0\lib\net8.0\System.CodeDom.dll' and 'Reference:C:\Program Files\dotnet\packs\Microsoft.WindowsDesktop.App.Ref\8.0.1\ref/net8.0/System.CodeDom.dll'. Choosing 'Reference:C:\Program Files\dotnet\packs\Microsoft.WindowsDesktop.App.Ref\8.0.1\ref/net8.0/System.CodeDom.dll' because file version '8.0.123.58001' is greater than '8.0.23.53103'.

Encountered conflict between 'Platform:System.CodeDom.dll' and 'CopyLocal:[REDACTED]\.nuget\packages\system.codedom\8.0.0\lib\net8.0\System.CodeDom.dll'. Choosing 'CopyLocal:[REDACTED]\.nuget\packages\system.codedom\8.0.0\lib\net8.0\System.CodeDom.dll' because file version '8.0.23.53103' is greater than '8.0.23.52016'.

It seems that, when .NET SDK chooses 'Platform:System.CodeDom.dll', it does not copy that to the output directory; but the reason for choosing that is not always the same.

"C:\Program Files\dotnet\packs\Microsoft.WindowsDesktop.App.Ref\8.0.1\data\PlatformManifest.txt" lists:

System.CodeDom.dll|Microsoft.WindowsDesktop.App.Ref|8.0.0.0|8.0.23.52016

Each line is formatted as fileName|packageId|assemblyVersion|fileVersion. Maybe it's a bug that the last number on this line is 8.0.23.52016 even though the file version of "C:\Program Files\dotnet\packs\Microsoft.WindowsDesktop.App.Ref\8.0.1\ref\net8.0\System.CodeDom.dll" is higher 8.0.123.58001. How are these PlatformManifest.txt files generated?

@danmoseley
Copy link
Member

cc @ericstj in case he knows why

@ericstj
Copy link
Member

ericstj commented Feb 12, 2024

The PlatformManifests doesn't assume a serviced runtime - they are supposed to contain the versions of platform at GA. The SDK then decides what to ship based on what's newer than GA. When you build an app that targets net8.0 the SDK can't predict if you'll run the app on 8.0.0 or 8.0.n.

In .NET 7 - the platform manifest had the exact match of the build versions that were shipped in 7.0 packages (which is expected). So the SDK chose to drop the packages in favor of the copy from the runtime.

In 8.0 I observe the following

From C:\Program Files\dotnet\packs\Microsoft.WindowsDesktop.App.Ref\8.0.0\data\PlatformManifest.txt

System.CodeDom.dll|Microsoft.WindowsDesktop.App.Ref|8.0.0.0|8.0.23.53103

From C:\Program Files\dotnet\packs\Microsoft.WindowsDesktop.App.Ref\8.0.1\data\PlatformManfiest.txt

System.CodeDom.dll|Microsoft.WindowsDesktop.App.Ref|8.0.0.0|8.0.23.52016

The 8.0.0 targeting pack was correct, the 8.0.1 targeting pack is incorrect. Looks like the versions went backwards. This will cause any 8.0 package that overlaps with WindowsDesktop to ship with the app even if it's the same version.

This is somewhat harmless as it's normal for packages to ship in the app once serviced (since the SDK cannot assume a serviced shared framework) but it is undesirable for application size.

@ericstj ericstj transferred this issue from dotnet/sdk Feb 12, 2024
@ericstj
Copy link
Member

ericstj commented Feb 12, 2024

@lonitra @ViktorHofer please have a look. It seems the platformmanifest for WindowsDesktop has the wrong file versions in servicing. I think https://github.com/dotnet/windowsdesktop/blob/release/8.0/src/windowsdesktop/src/sfx/PlatformManifest.txt needs to be updated with the exact content that shipped at GA.

@ViktorHofer
Copy link
Member

Sorry but I don't have any context on this. @lonitra PTAL

@lonitra
Copy link
Member

lonitra commented Feb 13, 2024

Fix will be available in .NET 8 March servicing release.

@EatonZ
Copy link
Author

EatonZ commented Feb 13, 2024

@lonitra Awesome, thanks a lot for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants