dotnet / project-system

The .NET Project System for Visual Studio
MIT License
968 stars 387 forks source link

XAML Designer throws when ProjectReference.ReferenceOutputAssembly is false #7831

Open znakeeye opened 2 years ago

znakeeye commented 2 years ago

Visual Studio Version

Microsoft Visual Studio Enterprise 2022 Version 17.0.2 VisualStudio.17.Release/17.0.2+31919.166 Microsoft .NET Framework Version 4.8.04084

Summary

See attached sample project! I have a WPF app project which loads WPF plugins from a "Modules" folder. Thus, no project references! In order to enforce the build system to build these plugin projects when hitting F5 (Debug) we came up with this quite clever trick for our .exe project:

<ItemGroup Label="ModuleDependencies">
    <ModuleLibs Include="../../../Modules/**/*.csproj" />
    <!-- Tell MSBuild to first build our module projects. -->
    <ProjectReference Include="@(ModuleLibs)" ReferenceOutputAssembly="false" />
</ItemGroup>

This works flawlessly, except for the WPF designer. It seems it is unable to resolve/deploy the necessary dependencies even though this User Control library has no dependencies at all.

designer-error

Steps to Reproduce

  1. Open sample project in VS 2022. wpf-designer-problem.zip

  2. Rebuild.

  3. Open MyViewA.xaml. The DataTemplate shows an error.

Expected Behavior

The designer should pick up the needed assemblies.

Actual Behavior

The designer shows an error.

User Impact

WPF productivity is greatly reduced.

tmeschter commented 2 years ago

@znakeeye Is PluginA.ViewModels.MyOtherViewModelA defined in one of the referenced projects, or in the current project?

znakeeye commented 2 years ago

@znakeeye Is PluginA.ViewModels.MyOtherViewModelA defined in one of the referenced projects, or in the current project?

As you can see in the provided sample project, that viewmodel is defined in a plugin for which there is no strong reference (ReferenceOutputAssembly="false"). I guess the designer somehow needs to get hold of these plugins.