mfkl / libvlc-nuget

NuGet packaging setup for LibVLC
GNU Lesser General Public License v2.1
63 stars 10 forks source link

Cherry picking files, revert on build. #22

Closed ShemJM closed 5 years ago

ShemJM commented 5 years ago

I have followed the guide on cherry picking which files I want to keep. When I load the project, the files I have chosen are in the solution explorer, which I think is not supposed to happen. Then when I build the project the include/exclude lines are removed from my project file.

The other libvlc lines stay in place, the one where I disable the x64 files for example.

I am working on a Visual Basic Winforms app, using libvlc and the dotnet.vlc.forms packages.

jeremyVignelles commented 5 years ago

Are you using a Sdk-style vbproj format or a legacy format? I think that we only support SDK-style project files, or at least only the new PackageReference system (and not the packages.config file). Can you send us a project reproducing the issue on a github repository?

ShemJM commented 5 years ago

I haven't been able to replicate the exact same problem. I have made this very quickly but this does not exclude the files I have set in the project file.

I am very sure that I am doing this wrong. I created the app, used Nuget package manager to get libvlc and dotnet.vlc.forms then I added the lines into the project file and built the solution. It just ignores my lines and adds everything to the debug folder.

I guess I am using legacy style if I have a packages config file.

I really only need the files for streaming a rtsp feed, so no sound, gui or anything else.

https://github.com/ShemJM/WindowsApp1/tree/master/WindowsApp1

jeremyVignelles commented 5 years ago

Your PropertyGroup and ItemGroup sections must be directly under the <Project> tag, not under the <Target>.

Yes, you are using the legacy project format, but maybe that will work anyway. Just keep in mind that VisualStudio does what it wants in that files. I guess that it's what happened, it replaced the target content with what it read from the packages.

ShemJM commented 5 years ago

I have migrated to a package reference style. It seems to be working better because the exclude/include lines are not being removed. The problem is that when I load my project the files mentioned in those lines whether they are excluded or included are being placed in to my solution explorer.

<ItemGroup>
    <VlcWindowsX86IncludeFiles Include="libvlc.dll;libvlccore.dll" />
  </ItemGroup>

image

UPDATE:

Just after writing this message, I reloaded the project and the lines were gone. It seems if I delete the files from the solution explorer, the lines are removed from the project file.

jeremyVignelles commented 5 years ago

If you remove them from Visual studio, of course it does remove the lines in your project file.

However, those file should not appear in your solution explorer and I'm still wondering why they do...

EDIT: Please update your github repo so that we can try locally.

ShemJM commented 5 years ago

I have made this repo where the same issue is occurring.

https://github.com/ShemJM/WindowsApp1

It is just an example project because the project I am working on where I had the original issue is not public. I am not sure how helpful the repo will be. Perhaps it would be easier to follow my steps and see if you experience the same issue.

  1. Create new visual basic winforms application
  2. Use nuget package manager to download vlc.dotnet.forms and VideoLAN.LibVLC.Windows.
  3. Unload the project.
  4. Add the exclude lines to the vbproj file. Save.
  5. Reload project. Files are now in the solution explorer.

I should add that my app is working I can use the vlc control to play videos. I just want to cherry pick the files so I can get the install size down.

jeremyVignelles commented 5 years ago

It seems that because you are not using the SDK-style projects, VS displays the items this way.

Can you try wrapping your ItemGroup in a

<Target Name="LibVlcWindowsCherryPick" BeforeTargets="CollectVlcFilesToCopyWindows">
</Target>

That should work. (note: you can pick whatever Name you want, but don't touch the BeforeTargets, it's defined here https://github.com/mfkl/libvlc-nuget/blob/ff6474f9505a0012f7ef5da80866a7429bd55902/build/VideoLAN.LibVLC.Windows.targets#L16 )

ShemJM commented 5 years ago

Yes, that works, thank you.

  <Target Name="LibVlcWindowsCherryPick" BeforeTargets="CollectVlcFilesToCopyWindows">
    <ItemGroup>
      <VlcWindowsX86ExcludeFiles Include="hrtfs\%2A%2A;
                                 lua\%2A%2A;
                                 locale\%2A%2A;
                                 plugins\audio_filter\%2A;
                                 plugins\audio_mixer\%2A;
                                 plugins\audio_output\%2A;
                                 plugins\access_output\%2A;
                                 plugins\control\%2A;
                                 plugins\d3d9\%2A;
                                 plugins\d3d11\%2A;
                                 plugins\demux\%2A;
                                 plugins\gui\%2A;
                                 plugins\keystore\%2A;
                                 plugins\logger\%2A;
                                 plugins\lua\%2A;
                                 plugins\meta_engine\%2A;
                                 plugins\mux\%2A;
                                 plugins\text_renderer\%2A;
                                 plugins\visualization\%2A;
                                 plugins\video_chroma\%2A;
                                 " />
    </ItemGroup>
  </Target>
mfkl commented 5 years ago

Feel free to close this if you got your question answered ;-)

jeremyVignelles commented 5 years ago

plugins\d3d11\%2A;

I wouldn't recommend you to disable those, you won't get any hw acceleration if you do

plugins\demux\%2A;

Did you test that one? I'm not sure that would work without any demuxer.

plugins\access_output\%2A;

I had crashes if I didn't include at least mmdevice on windows... don't know if this has been fixed since then.

ShemJM commented 5 years ago

I am only using this for a rtsp stream from our IP cameras. It seems to work fine without those files. I don't know much about the different options. I was just trying to use the bare minimum because by adding LibVLC my project size has gone from 12MB to 63MB. That is after cherry picking because at first it was 320MB.

jeremyVignelles commented 5 years ago

I think you can shrink it further by including only what you need. in codec, you could try with only libavcodec... you will also probably need only rtsp and rtp access.

jeremyVignelles commented 5 years ago

but I would keep d3d libs for hardware acceleration

ShemJM commented 5 years ago

I was going to ask for advice on how to shrink it further, so thank you again. I will try without those.

ShemJM commented 5 years ago

Sorry, one more question. I have managed to find the small amount of files I actually need. Is there a way for me to just write lines to include those rather than lines that exclude everything else?

jeremyVignelles commented 5 years ago

Yes, that was what I suggested : https://github.com/mfkl/libvlc-nuget/blob/master/cherry-picking.md#cherry-pick-the-files-you-need

ShemJM commented 5 years ago

I did try an inclusive strategy but it just included every file. That is why I moved to exclusive.

jeremyVignelles commented 5 years ago

That shouldn't be, please share a sample

ShemJM commented 5 years ago

Well I just copied from your example

  <Target Name="LibVlcWindowsCherryPick" BeforeTargets="CollectVlcFilesToCopyWindows">
    <ItemGroup>
      <VlcWindowsX86IncludeFiles Include="libvlc.dll" />
    </ItemGroup>
  </Target>

Something like that, but that would include every file still

jeremyVignelles commented 5 years ago

Use

  <Target Name="LibVlcWindowsCherryPick" BeforeTargets="CollectVlcFilesToCopyWindows">
    <ItemGroup>
      <VlcWindowsX86IncludeFiles Remove="@(VlcWindowsX86IncludeFiles)" />
      <VlcWindowsX86IncludeFiles Include="libvlc.dll" />
    </ItemGroup>
  </Target>

Since you are using a target, your "Include" adds an item to the list that has already populated here : https://github.com/mfkl/libvlc-nuget/blob/ff6474f9505a0012f7ef5da80866a7429bd55902/build/VideoLAN.LibVLC.Windows.targets#L13

You thus need to remove the default items.

ShemJM commented 5 years ago

I see, that makes sense. I will try it out tomorrow when I am at work. Thanks again :D

ShemJM commented 5 years ago

Works perfectly.