Upgrade template to 10.9.x and .NET 8

This commit is contained in:
Shadowghost 2024-10-05 16:44:52 +02:00
parent 2c1143b49f
commit 3afa1fc407
7 changed files with 37 additions and 22 deletions

2
.vscode/launch.json vendored
View File

@ -7,7 +7,7 @@
"name": "Launch", "name": "Launch",
"request": "launch", "request": "launch",
"preLaunchTask": "build-and-copy", "preLaunchTask": "build-and-copy",
"program": "${config:jellyfinDir}/bin/Debug/net6.0/jellyfin.dll", "program": "${config:jellyfinDir}/bin/Debug/net8.0/jellyfin.dll",
"args": [ "args": [
//"--nowebclient" //"--nowebclient"
"--webdir", "--webdir",

4
.vscode/tasks.json vendored
View File

@ -59,14 +59,14 @@
"command": "cp", "command": "cp",
"windows": { "windows": {
"args": [ "args": [
"./${config:pluginName}/bin/Debug/net6.0/publish/*", "./${config:pluginName}/bin/Debug/net8.0/publish/*",
"${config:jellyfinWindowsDataDir}/plugins/${config:pluginName}/" "${config:jellyfinWindowsDataDir}/plugins/${config:pluginName}/"
] ]
}, },
"linux": { "linux": {
"args": [ "args": [
"-r", "-r",
"./${config:pluginName}/bin/Debug/net6.0/publish/*", "./${config:pluginName}/bin/Debug/net8.0/publish/*",
"${config:jellyfinLinuxDataDir}/plugins/${config:pluginName}/" "${config:jellyfinLinuxDataDir}/plugins/${config:pluginName}/"
] ]
} }

View File

@ -1,15 +1,28 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
#
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jellyfin.Plugin.Template", "Jellyfin.Plugin.Template\Jellyfin.Plugin.Template.csproj", "{D921B930-CF91-406F-ACBC-08914DCD0D34}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jellyfin.Plugin.Template", "Jellyfin.Plugin.Template\Jellyfin.Plugin.Template.csproj", "{D921B930-CF91-406F-ACBC-08914DCD0D34}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D921B930-CF91-406F-ACBC-08914DCD0D34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D921B930-CF91-406F-ACBC-08914DCD0D34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D921B930-CF91-406F-ACBC-08914DCD0D34}.Debug|Any CPU.Build.0 = Debug|Any CPU {D921B930-CF91-406F-ACBC-08914DCD0D34}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D921B930-CF91-406F-ACBC-08914DCD0D34}.Debug|x64.ActiveCfg = Debug|Any CPU
{D921B930-CF91-406F-ACBC-08914DCD0D34}.Debug|x64.Build.0 = Debug|Any CPU
{D921B930-CF91-406F-ACBC-08914DCD0D34}.Debug|x86.ActiveCfg = Debug|Any CPU
{D921B930-CF91-406F-ACBC-08914DCD0D34}.Debug|x86.Build.0 = Debug|Any CPU
{D921B930-CF91-406F-ACBC-08914DCD0D34}.Release|Any CPU.ActiveCfg = Release|Any CPU {D921B930-CF91-406F-ACBC-08914DCD0D34}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D921B930-CF91-406F-ACBC-08914DCD0D34}.Release|Any CPU.Build.0 = Release|Any CPU {D921B930-CF91-406F-ACBC-08914DCD0D34}.Release|Any CPU.Build.0 = Release|Any CPU
{D921B930-CF91-406F-ACBC-08914DCD0D34}.Release|x64.ActiveCfg = Release|Any CPU
{D921B930-CF91-406F-ACBC-08914DCD0D34}.Release|x64.Build.0 = Release|Any CPU
{D921B930-CF91-406F-ACBC-08914DCD0D34}.Release|x86.ActiveCfg = Release|Any CPU
{D921B930-CF91-406F-ACBC-08914DCD0D34}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<RootNamespace>Jellyfin.Plugin.Template</RootNamespace> <RootNamespace>Jellyfin.Plugin.Template</RootNamespace>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@ -11,13 +11,13 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Jellyfin.Controller" Version="10.8.13" /> <PackageReference Include="Jellyfin.Controller" Version="10.9.1" />
<PackageReference Include="Jellyfin.Model" Version="10.8.13" /> <PackageReference Include="Jellyfin.Model" Version="10.9.11" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" /> <PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507" PrivateAssets="All" /> <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556" PrivateAssets="All" />
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" /> <PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
</ItemGroup> </ItemGroup>

View File

@ -39,13 +39,13 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
/// <inheritdoc /> /// <inheritdoc />
public IEnumerable<PluginPageInfo> GetPages() public IEnumerable<PluginPageInfo> GetPages()
{ {
return new[] return
{ [
new PluginPageInfo new PluginPageInfo
{ {
Name = this.Name, Name = Name,
EmbeddedResourcePath = string.Format(CultureInfo.InvariantCulture, "{0}.Configuration.configPage.html", GetType().Namespace) EmbeddedResourcePath = string.Format(CultureInfo.InvariantCulture, "{0}.Configuration.configPage.html", GetType().Namespace)
} }
}; ];
} }
} }

View File

@ -1,10 +1,10 @@
# So you want to make a Jellyfin plugin # So you want to make a Jellyfin plugin
Awesome! This guide is for you. Jellyfin plugins are written using the dotnet standard framework. What that means is you can write them in any language that implements the CLI or the DLI and can compile to net6.0. The examples on this page are in C# because that is what most of Jellyfin is written in, but F#, Visual Basic, and IronPython should all be compatible once compiled. Awesome! This guide is for you. Jellyfin plugins are written using the dotnet standard framework. What that means is you can write them in any language that implements the CLI or the DLI and can compile to net8.0. The examples on this page are in C# because that is what most of Jellyfin is written in, but F#, Visual Basic, and IronPython should all be compatible once compiled.
## 0. Things you need to get started ## 0. Things you need to get started
- [Dotnet SDK 6.0](https://dotnet.microsoft.com/download) - [Dotnet SDK 8.0](https://dotnet.microsoft.com/download)
- An editor of your choice. Some free choices are: - An editor of your choice. Some free choices are:
@ -39,7 +39,7 @@ If you'd rather start from scratch keep going on to step one. This assumes no sp
Make a new dotnet standard project with the following command, it will make a directory for itself. Make a new dotnet standard project with the following command, it will make a directory for itself.
``` ```
dotnet new classlib -f net6.0 -n MyJellyfinPlugin dotnet new classlib -f net8.0 -n MyJellyfinPlugin
``` ```
Now add the Jellyfin shared libraries. Now add the Jellyfin shared libraries.
@ -126,7 +126,9 @@ If your plugin doesn't fit perfectly neatly into a predefined interface, never f
- **IPluginConfigurationPage** - Allows you to have a plugin config page on the dashboard. If you used one of the quickstart example projects, a premade page with some useful components to work with has been created for you! If not you can check out this guide here for how to whip one up. - **IPluginConfigurationPage** - Allows you to have a plugin config page on the dashboard. If you used one of the quickstart example projects, a premade page with some useful components to work with has been created for you! If not you can check out this guide here for how to whip one up.
- **IServerEntryPoint** - Allows you to run code at server startup that will stay in memory. You can make as many of these as you need and it is wildly useful for loading configs or persisting state. **Be aware that your main plugin class (IBasePlugin) cannot also be a IServerEntryPoint.** **IPluginServiceRegistrator** - Will be located by Jellyfin at server startup and allows you to add services to the DI container to allow for injection in your plugin's classes later.
- **IHostedService** - Allows you to run code as a background task that will be started at program startup and will remain in memory. See [Microsoft's documentation](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-8.0&tabs=visual-studio#ihostedservice-interface) for more information. You can make as many of these as you need; make Jellyfin aware of them with an `IPluginServiceRegistrator`. It is wildly useful for loading configs or persisting state. **Be aware that your main plugin class (IBasePlugin) cannot also be a IHostedService.**
- **ControllerBase** - Allows you to define custom REST-API endpoints. This is the default ASP.NET Web-API controller. You can use it exactly as you would in a normal Web-API project. Learn more about it [here](https://docs.microsoft.com/aspnet/core/web-api/?view=aspnetcore-5.0). - **ControllerBase** - Allows you to define custom REST-API endpoints. This is the default ASP.NET Web-API controller. You can use it exactly as you would in a normal Web-API project. Learn more about it [here](https://docs.microsoft.com/aspnet/core/web-api/?view=aspnetcore-5.0).
@ -220,7 +222,7 @@ This example expects you to clone `jellyfin`, `jellyfin-web` and `jellyfin-plugi
"name": "Launch", "name": "Launch",
"request": "launch", "request": "launch",
"preLaunchTask": "build-and-copy", "preLaunchTask": "build-and-copy",
"program": "${config:jellyfinDir}/bin/Debug/net6.0/jellyfin.dll", "program": "${config:jellyfinDir}/bin/Debug/net8.0/jellyfin.dll",
"args": [ "args": [
//"--nowebclient" //"--nowebclient"
"--webdir", "--webdir",
@ -288,7 +290,7 @@ This example expects you to clone `jellyfin`, `jellyfin-web` and `jellyfin-plugi
"type": "shell", "type": "shell",
"command": "cp", "command": "cp",
"args": [ "args": [
"./${config:pluginName}/bin/Debug/net6.0/publish/*", "./${config:pluginName}/bin/Debug/net8.0/publish/*",
"${config:jellyfinDataDir}/plugins/${config:pluginName}/" "${config:jellyfinDataDir}/plugins/${config:pluginName}/"
] ]
@ -356,7 +358,7 @@ This example expects you to clone `jellyfin`, `jellyfin-web` and `jellyfin-plugi
"type": "shell", "type": "shell",
"command": "cp", "command": "cp",
"args": [ "args": [
"./${config:pluginName}/bin/Debug/net6.0/publish/*", "./${config:pluginName}/bin/Debug/net8.0/publish/*",
"${config:jellyfinDataDir}/plugins/${config:pluginName}/" "${config:jellyfinDataDir}/plugins/${config:pluginName}/"
] ]
}, },

View File

@ -2,8 +2,8 @@
name: "Template" name: "Template"
guid: "eb5d7894-8eef-4b36-aa6f-5d124e828ce1" guid: "eb5d7894-8eef-4b36-aa6f-5d124e828ce1"
version: "1.0.0.0" version: "1.0.0.0"
targetAbi: "10.8.0.0" targetAbi: "10.9.0.0"
framework: "net6.0" framework: "net8.0"
overview: "Short description about your plugin" overview: "Short description about your plugin"
description: > description: >
This is a longer description that can span more than one This is a longer description that can span more than one