kuiperzone / AvantGarde

Avalonia XAML Preview for Linux and Windows
GNU General Public License v3.0
228 stars 10 forks source link

Projects using class libraries have issues finding the Avalonia version #32

Closed HuygheDaphne-Marie closed 10 months ago

HuygheDaphne-Marie commented 11 months ago

I have a project with a class library which seemed to cause issues for the editor when I opened it and set my App project. I managed to find a workaround but I think I narrowed down the issue.

image

The class library includes avalonia and everything else needed to run things properly but the .client.desktop project doesn't include Avalonia itself which the previewer complained about saying "Version cannot be 'null'". I managed to fix this by including Avalonia in the client.desktop project file but it would be cool if the previewer was able to find the Avalonia version the class library used.

image

It didn't seem able to resolve $(AvaloniaVersion) (to be fair I don't have any idea where this is defined either) in the project file, but I've just set the specific version.

It'd be cool if the desktop project would use the Avalonia version of the class library, and maybe also resolve the version somehow.

Thanks for the awesome project though ❤

kuiperzone commented 11 months ago

Thank you for the detailed explanation. I will have to give this some thought regarding finding the Avalonia version from the class library. It is not immediately apparent to me, but it may turn out to be possible.

One of possibility is to have an option in the project window to forceably set the version. Needs some thought.

Will look into this in the next release. Thank you.

kuiperzone commented 10 months ago

I suspect your $AvaloniaVersion may be defined in a Directory.Build.props file.

I've added the ability in v1.4 to set the version in cases it is NOT in the csproj file. Notes below...

Normally, Avant Garde will detect the Avalonia version from your project .csproj file. There are certain instances when your project may not include the Avalonia package directly, but instead reference another class library which does. In this case, you must set the Avalonia version yourself which must be installed in your development environment.

image