Skip to content

Commit 3e430fe

Browse files
jasellsmfkl
authored andcommitted
maui: add shell net8.0 target to support adding package to non-shared project solution structures
1 parent 940c549 commit 3e430fe

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/LibVLCSharp.MAUI/AppHostBuilderExtensions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@ public static MauiAppBuilder UseLibVLCSharp(this MauiAppBuilder builder)
1515
// Register LibVLCSharp handlers
1616
builder.ConfigureMauiHandlers(handlers =>
1717
{
18+
#if ANDROID || IOS || WINDOWS
1819
handlers.AddHandler(typeof(VideoView), typeof(VideoViewHandler));
20+
#else
21+
//.net8 core has no impl, but we need to define it so that the package can be added to a .Net8 x-plat project
22+
// for linking purposes. At runtime, the correct platform-specific lib will be loaded, as any Maui-app solution will
23+
// also contain a platform-specific project targeting one of the supported targets (Android, iOS, WinUI),
24+
// or will be a shared-project.
25+
throw new NotImplementedException($"This exception means the current target plaftorm: {DeviceInfo.Current.Platform} is not supported or correctly initialized. VLC needs platform-specific libs loaded.");
26+
#endif
1927
});
2028

2129
// Configure custom fonts

src/LibVLCSharp.MAUI/Handlers/VideoViewHandler.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
using VideoViewImpl = LibVLCSharp.Platforms.iOS.VideoView;
66
#elif WINUI
77
using VideoViewImpl = LibVLCSharp.Platforms.Windows.VideoView;
8+
#else //.Net 8 (core/x-plat)
9+
using VideoViewImpl = LibVLCSharp.Shared.IVideoView;
810
#endif
911

1012
namespace LibVLCSharp.MAUI
@@ -25,8 +27,14 @@ protected override VideoViewImpl CreatePlatformView()
2527
{
2628
#if ANDROID
2729
return new VideoViewImpl(Context);
28-
#else
30+
#elif IOS || WINUI
2931
return new VideoViewImpl();
32+
#else
33+
//.net8 core has no impl, but we need to define it so that the package can be added to a .Net8 x-plat project
34+
// for linking purposes. At runtime, the correct platform-specific lib will be loaded, as any Maui-app solution will
35+
// also contain a platform-specific project targeting one of the supported targets (Android, iOS, WinUI),
36+
// or will be a shared-project.
37+
throw new NotImplementedException($"This exception means the current target plaftorm: {DeviceInfo.Current.Platform} is not supported or correctly initialized. VLC needs platform-specific libs loaded.");
3038
#endif
3139
}
3240
}

src/LibVLCSharp.MAUI/LibVLCSharp.MAUI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net8.0-android;net8.0-ios</TargetFrameworks>
3+
<TargetFrameworks>net8.0;net8.0-android;net8.0-ios</TargetFrameworks>
44
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041</TargetFrameworks>
55
<UseMaui>true</UseMaui>
66
<SingleProject>true</SingleProject>

0 commit comments

Comments
 (0)