kuiperzone / AvantGarde

Avalonia XAML Preview for Linux and Windows

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Avant Garde blocks project from building

Kacper-Kondracki opened this issue · comments

Avant Garde blocks project from building for me.
It seems that to reproduce this issue you need to open solution in Avant Garde, open a view to preview and then make some change to xaml code. After that C# project is no longer buildable giving this error message.

The process cannot access
the file 'C:\Users\Kacper\RiderProjects\MyApp\MyApp\bin\Debug\net7.0\MyApp.dll' because it is being used by another pro
cess.

OS: Windows 11

It would really be nice if I could compile my project without closing Avant Garde.

Thank you.

When I first developed this app, this issue did not exist. In recent times, however, I've experienced it myself on Linux and have wondered how got introduced...

Avant Garde itself should not be locking any files. It keeps a tree of file items (PathItem class and subclasses thereof), but this only uses FileInfo and DirectoryInfo internally. Certainly, there is no reason why DLLs should be locked.

Avant Garde does, however, launch the Avalonia "design host" application which does the actual preview generation. I suspect it is this which might be locking the files. I'll do a little investigation on where to pin the "blame". If transpires that it is the design host, then there's nothing which can be done from Avant Garde. If it's AG, however, I'll fix it.

Doesn't seem to be doing this any longer, at least on Linux.

Seems like this is still happening, I'm running into this issue
1>warning MSB3026: Could not copy "obj\Debug\net7.0\DiGaMe.Client.dll" to "bin\Debug\net7.0\DiGaMe.Client.dll". Beginning retry 1 in 1000ms. The process cannot access the file 'bin\Debug\net7.0\DiGaMe.Client.dll' because it is being used by another process. The file is locked by: ".NET Host (8620)"

it then tries 10 times and fails the build, once the previewer is closed it works again so it's definitely what's locking the file. This is happening on a project with multiple deploy targets so it's using a class libraray, I doubt that's what is causing the issue though.

I've tried a workaround by providing Avant Garde with a copy made by a post build event.
image

This lets the build complete but introduces a new issue, since the previewer seems to use the name of the .dll to find files referenced in the .axaml instead of the name of the project.
image

See linked issue below for updates:

AvaloniaUI/Avalonia#13850

@HuygheDaphne-Marie

Hi, I see you are running Avant Garde on Windows. Can I ask, why you are using Avant Garde instead of the Visual Studio Avalonia plugin?

I ask because I wrote Avant Garde primarily because, at the time, there was no preview solution on Linux. However, there is now an Avalonia plugin for VS Code. Although still in alpha, I suspect the plugin will get better.

So, preview solutions now exist on both Windows and Linux. Avant Garde is a little different to these in that it is standalone and not a plugin.

What would be really helpful to me is to understand why people may continue to want to use Avant Garde in the future so that I may concentrate on use cases that are not perhaps available in plugins?

@kuiperzone
I've been using it since there was no way I could find to pop out the design preview. Which provides a nicer development experience for me. I've looked around in their settings and the like and wasn't able to find any method of doing this.

Good to know. Thanks

I'm hoping this will be "fixed" (twas the preview host that broke it) in version 1.4.