2

I have an intermitted build issues related to LibVLCSharp and the bin\Debug outputs.

When I build a Solution containing a LibVLCSharp Project, I can see the libvlc.dll in the final win-x64 output folder, but when I start debugging, the following files get deleted, and the application fails with :

LibVLCSharp.Shared.VLCException: 'Failed to load required native libraries. 
Have you installed the latest LibVLC package from nuget for your target platform?

The only only files that get deleted are:

  • libvlc.dll
  • libvlc.lib
  • libvlccore.dll
  • libvlccore.lib

It's an intermitted issues and seems to get resolved when I reboot.

Under what conditions would files in the Solution output folder get purged at Debug Startup?

bin\Debug\net5.0-windows\libvlc\win-x64\ 

I can manually get around this by copying the files back, but I'm trying to understand why this is happening.

There are no pre or post build steps in the Solution.

LibVlcSharp files getting deleted at Visual Studio Debug startup

mcolhoun
  • 489
  • 4
  • 11
  • Is the LibVLC package properly installed on the Starter project? (It should not be installed on the others project but on the project you start. – cube45 Oct 15 '21 at 14:12
  • 1
    Otherwise, we would need a minimal reproducible project for us to test. Do you have something special around the msbuild targets? – cube45 Oct 15 '21 at 14:13
  • Can it have something to do with your "Fullfilled.Tasks" projects? – cube45 Oct 15 '21 at 14:14
  • Can you use the `copy always` attribute on these files? – Jiale Xue - MSFT Oct 18 '21 at 06:49
  • @cube45 - I have the LibVLC installed in the Tasks project where the libvlcsharp api is referenced, but not in the Startup project (Starter). This may be the issue - it makes sense as I never need to "compile" the libvlc.dll, just link it to the startup app, and the libvlvsharp needs to be added as a reference in the project where I use the api. Good catch. I have nothing special around msbuild projects, all are defaults. Let me test and revert to you. thanks! – mcolhoun Oct 19 '21 at 12:11

1 Answers1

3

The LibVLC-nuget project is meant to be refereced directly in the startup project.

This is because we embed target files in the NuGet packages that creates a Task that executes BeforeBuild, and I'm not sure how that would work in referenced projects. You can see it there : https://github.com/mfkl/libvlc-nuget/blob/56178d3d4fd4d5b4874d41e5e9de07116be4cb64/build/VideoLAN.LibVLC.Windows.targets#L16

I'm pretty sure msbuild does not rebuild your dependent project every time, thus not catching the conditional "Content" files.

We do this, because otherwise the visual studio project tree would be filled with every .dll files from the plugins folder, which would slow down the visual studio process.

cube45
  • 3,429
  • 2
  • 24
  • 35