winforms icon indicating copy to clipboard operation
winforms copied to clipboard

.NET Designer and NuGet packages for UI: Problems when runtime is in ExcludeAssets

Open kuskitkd opened this issue 2 years ago • 2 comments

Environment

VS 17.12.0

.NET version

net8.0-windows

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

Worked in multitarget net472;net8.0-windows

Issue description

I am switching the support of our UI libraries/apps from using NETFramework 4.7.2 + NET 8 Windows to using only NET 8 Windows as part of the migration process to the latest .NET.

The UI uses third party libraries (DevExpress WinForms). To prevent copying of the DevExpress dlls to the output folder, those packages were originally configured as ExcludeAssets=runtime. This was done because the dlls end up being pulled into a different folder in the output tree through another project and this library is enhancing that one. The whole application is published later on via ClickOnce, so there cannot be duplicates anywhere on the folder published.

When having both frameworks, the designer run as for Framework and everything was OK. When having only NET 8 Windows, the designer seems to need to consume the content of the lib folder for all DevExpress packages or the in-place designer in VisualStudio does not work. So ExcludeAssets=runtime does not work anymore. After removing that, the designer works but dlls start appearing in folders where they should not be (and causing ClickOnce issues).

I tested several combinations of asset configurations, just in case the issue was with the assets, but there does not seem to be a way to have the contents in the lib folder used for the designer but not copy them out to the output folder.

Combinations tested: IncludeAssets: (default); PrivateAssets: (default), ExcludeAssets: (default) -> Dlls copied, Designer works IncludeAssets: (default); PrivateAssets: (default), ExcludeAssets: runtime -> Dlls not copied, Designer does not works IncludeAssets: (default); PrivateAssets: runtime, ExcludeAssets: (default) -> Dlls copied, Designer works IncludeAssets: (default); PrivateAssets: all, ExcludeAssets: (default) -> Dlls copied, Designer works IncludeAssets: compile; PrivateAssets: all, ExcludeAssets: (default) -> Dlls not copied, Designer doesn't work IncludeAssets: compile;runtime; PrivateAssets: all, ExcludeAssets: (default) -> Dlls copied, Designer works IncludeAssets: compile;runtime; PrivateAssets: all, ExcludeAssets: runtime -> Dlls not copied, Designer doesn't work

I asked in the NuGet repo but it was mentioned that how the packages are consumed is of no relevance to NuGet and that ExcludeAssets=runtime would prevent getting those copied to the output folder. The issue seems to be that the designer can only work with those files in the output folder.

For reference, the nupkg for the NuGet packages referenced looks as follows: Image

And the DesignToolsServer error: Image

Steps to reproduce

Steps mentioned in the description.

Diagnostics


kuskitkd avatar Nov 25 '24 17:11 kuskitkd

Try to set https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#copylocallockfileassemblies to false instead

FixBo avatar Nov 29 '24 10:11 FixBo

Hi, Finally had time to give a try to the solution mentioned by @FixBo . That seems to fix our problems.

In case anybody needs it for future reference, our UI projects (some exes, some libraries) have this in a PropertyGroup: false and DevExpress NuGet packages on those projects are configured with runtime in the private assets: runtime;contentfiles;analyzers;build <!--The default excludes + runtime-- >

This has the VS designer correctly loading the packages but all the extra dlls do not go to the various output folders, so ClickOnce does not encounter duplicates (all required NuGet references are getting restored through a dedicated project).

Considering that the issue is the requirements for running the designer when only targetting NET8.0 are different, it might be worth mentioning the NuGet setup might need to change and and that property listed somewhere on the documentation as a potentially relevant relevant information when switching from Framework or multitargetting Framework and NET8.0 to only NET8.0 and trying to use the VS Designer.

kuskitkd avatar Dec 10 '24 23:12 kuskitkd