dotnet / dotnet/winforms

WinformsDesigner copied all references for multitarget project (including DLLs from wrong target)

Open
#12,454 3 comments 0 reactions 0 assignees View on GitHub
area-VSDesigner
Dominant language
C#
Stars
4.9k
Forks
1.1k
Avg merge
20h 23m
Merged PRs (30d)
103

Description

### Environment

Version 17.10.6

### .NET version

Multitarget: net8;net472

### Did this work in a previous version of Visual Studio and/or previous .NET release?

No

### Issue description

When we're using multitarget project, that one is reference on another multitargeted project, winforms designer copies references into cache for both targets, causing often not working mix. If you're checking cache after that, there would be artefacts from previous target, like System.Memory.dll in my example

[23:00:43.040536] info: [Thread 485] Launching server...
[23:00:43.341536] info: Shadow cache base directory: C:\Users\XXX\AppData\Local\Microsoft\VisualStudio\17.0_d57e068e\WinFormsDesigner
[23:00:43.342536] info: [WinFormsApp3]: Preparing shadow cache folder.
[23:00:43.342536] info: [WinFormsApp3]: NetCoreServerLayout - Platform: AnyCPU, Normalized PlatformName: x64
[23:00:43.342536] info: [WinFormsApp3]: Copying design tools server common files from: 'c:\program files\microsoft visual studio\2022\professional\common7\ide\commonextensions\microsoft\windows.forms\DesignToolsServer\Common'.
[23:00:43.421536] info: [WinFormsApp3]: Copying design tool server platform-specific files from: 'c:\program files\microsoft visual studio\2022\professional\common7\ide\commonextensions\microsoft\windows.forms\DesignToolsServer\x64'.
[23:00:43.431536] info: [WinFormsApp3]: Copying project output file: 'C:\!!!Projects\Test\WinFormsApp3\bin\Debug**\net8.0-windows**\WinFormsApp3.dll'.
[23:00:43.433537] info: [WinFormsApp3]: Copying project reference: 'c:\views\!nuget\PackagesCache\system.buffers\4.5.1\lib\**net461**\System.Buffers.dll'.
[23:00:43.435536] info: [WinFormsApp3]: Copying project reference: 'c:\views\!nuget\PackagesCache\system.memory\4.5.5\lib**\net461\**System.Memory.dll'.
[23:00:43.436538] info: [WinFormsApp3]: Copying project reference: 'c:\views\!nuget\PackagesCache\system.numerics.vectors\4.5.0\lib\net46\System.Numerics.Vectors.dll'.
[23:00:43.438536] info: [WinFormsApp3]: Copying project reference: 'c:\views\!nuget\PackagesCache\system.runtime.compilerservices.unsafe\4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll'.
[23:00:43.439537] info: [WinFormsApp3]: Copying project reference: 'C:\!!!Projects\Test\ClassLibrary3\bin\Debug\**net472\ClassLibrary3.dll**'.
[23:00:43.440536] info: [WinFormsApp3]: Copying 'C:\!!!Projects\Test\WinFormsApp3\obj\Debug\net8.0-windows\WinFormsApp3.designer.deps.json' to 'DesignToolsServer.deps.json'
[23:00:43.442538] info: [WinFormsApp3]: Copying 'C:\!!!Projects\Test\WinFormsApp3\obj\Debug\net8.0-windows\WinFormsApp3.designer.runtimeconfig.json' to 'DesignToolsServer.runtimeconfig.json'
[23:00:43.443538] info: [WinFormsApp3]: Copying project reference: 'C:\!!!Projects\Test\ClassLibrary3\bin\Debug**\net8.0\ClassLibrary3.dll**'.
[23:00:43.479537] info: Shadow caching completed.

### Steps to reproduce

1. Create 2 projects (WinFormsApp and ClassLibrary), both with multitarget, say net8-windows and net472.
2. Let's project ClassLibrary is dll, with reference on net472 specific stuff (say, System.Memory package. there is no files there for net8)
3. Project WinFormsApp is using winforms and reference on project ClassLibrary
4. Open designer and check cache folder. There would be dependencies from net472 targeted project, albeit project WinFormsApp and ClassLibrary dlls is targeted to net8.[winforms-multitarget.zip](https://github.com/user-attachments/files/17686376/winforms-multitarget.zip)

### Diagnostics

```text
[23:00:43.342536] info: [WinFormsApp3]: Preparing shadow cache folder.
[23:00:43.342536] info: [WinFormsApp3]: NetCoreServerLayout - Platform: AnyCPU, Normalized PlatformName: x64
[23:00:43.342536] info: [WinFormsApp3]: Copying design tools server common files from: 'c:\program files\microsoft visual studio\2022\professional\common7\ide\commonextensions\microsoft\windows.forms\DesignToolsServer\Common'.
[23:00:43.421536] info: [WinFormsApp3]: Copying design tool server platform-specific files from: 'c:\program files\microsoft visual studio\2022\professional\common7\ide\commonextensions\microsoft\windows.forms\DesignToolsServer\x64'.
[23:00:43.431536] info: [WinFormsApp3]: Copying project output file: 'C:\!!!Projects\Test\WinFormsApp3\bin\Debug\net8.0-windows\WinFormsApp3.dll'.
[23:00:43.433537] info: [WinFormsApp3]: Copying project reference: 'c:\views\!nuget\PackagesCache\system.buffers\4.5.1\lib\net461\System.Buffers.dll'.
[23:00:43.435536] info: [WinFormsApp3]: Copying project reference: 'c:\views\!nuget\PackagesCache\system.memory\4.5.5\lib\net461\System.Memory.dll'.
[23:00:43.436538] info: [WinFormsApp3]: Copying project reference: 'c:\views\!nuget\PackagesCache\system.numerics.vectors\4.5.0\lib\net46\System.Numerics.Vectors.dll'.
[23:00:43.438536] info: [WinFormsApp3]: Copying project reference: 'c:\views\!nuget\PackagesCache\system.runtime.compilerservices.unsafe\4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll'.
[23:00:43.439537] info: [WinFormsApp3]: Copying project reference: 'C:\!!!Projects\Test\ClassLibrary3\bin\Debug\net472\ClassLibrary3.dll'.
[23:00:43.440536] info: [WinFormsApp3]: Copying 'C:\!!!Projects\Test\WinFormsApp3\obj\Debug\net8.0-windows\WinFormsApp3.designer.deps.json' to 'DesignToolsServer.deps.json'
[23:00:43.442538] info: [WinFormsApp3]: Copying 'C:\!!!Projects\Test\WinFormsApp3\obj\Debug\net8.0-windows\WinFormsApp3.designer.runtimeconfig.json' to 'DesignToolsServer.runtimeconfig.json'
[23:00:43.443538] info: [WinFormsApp3]: Copying project reference: 'C:\!!!Projects\Test\ClassLibrary3\bin\Debug\net8.0\ClassLibrary3.dll'.
[23:00:43.479537] info: Shadow caching completed.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.