AvaloniaVS
AvaloniaVS copied to clipboard
Designer looks at wrong DLL / Doesn't respect solution configuration
I have a solution with multiple configurations (two [Debug+Release] for each OS I want to support.
When I open a window XAML file the designer shows the following:
But my solution configuration is the following:
And the following project configuration should build:
Browsing through the code, I'd expect the problem comes from this method: https://github.com/AvaloniaUI/AvaloniaVS/blob/f18343c6fbe8fed90b8d3743b8c21483818f2eeb/AvaloniaVS.Shared/Views/AvaloniaDesigner.xaml.cs#L293
Hey,
I've had the same problem and tracked it down to this method: https://github.com/AvaloniaUI/AvaloniaVS/blob/34dfcf7c507c7ccdfe6408b2f680fa81b5eef089/AvaloniaVS.Shared/Services/SolutionService.cs#L198-L231
The logic just seem to take any first hit it finds, instead of taking into consideration active configuration.
Changing the line 224 with the following does force the extension to actually take into account active configuration:
var config = GetMsBuildProperty(msbuildProperties, "Configuration");
if (config.Equals(project.ConfigurationManager.ActiveConfiguration.ConfigurationName) || !alternatives.ContainsKey(tf))
{
alternatives[tf] = new ProjectOutputInfo(targetPath, tf, tfi, hostApp);
}
@bcssov hi, thanks for your findings! Do you want to open a PR with this change?
Though I am a bit confused with this issue and another similar https://github.com/AvaloniaUI/AvaloniaVS/pull/196
The issue for me was that the extension was looking for a release build instead of debug (I only had 2 configs: Debug and Release). The method that I've patched seems to take an unsorted list and just uses whatever comes last in the sequence. So in the current implementation it seems a random chance that the extension will take whatever configuration it does in the end. I got tired and decided not to dig deeper.
The PR you mentioned in progress attempts to fix the same issue, although it seems to be incomplete (and probably should be preferred way to go about it). All issues do seem to be all related at the sound of things.
In the end I've merely patched the current logic to get seemingly the same result which was easier given that all information was readily available.
Do you still want a PR then?
Closing as duplicate of https://github.com/AvaloniaUI/AvaloniaVS/issues/190