Use VSCode to develop Playnite extensions in Windows
Warning
This guide is not up to date with the latest changes made to C# development in VS Code and therefore not all steps might be correct.
Proper VS Code development doc will be made after Playnite transitions to modern .NET runtime with Playnite 11.
This is a step by step tutorial to build the Playnite extensions using VSCode.
Download and setup dependencies
- Install VSCode
- Install .NET SDK for VSCode
- Install .NET Framework 4.6.2 Developer Pack
- Install Visual Build Tools for Visual Studio 2015 with Update 3 (Requires registration)
- Install C# extension in VSCode
- Install nuget (If in doubt, follow the instruction in Microsoft Docs, and be sure to add it to the path!)
Prepare your project folder
- Create the project using toolbox.exe
- Open the project folder in VSCode
- In VSCode, press
ctrl+shit+P
, typeTerminal: Create New Terminal
and pressEnter
- Create a new
AssemblyInfo.cs
file:
Get-Content .\Properties\AssemblyInfo.cs | Where-Object {$_ -notmatch '^\[assembly: Assembly.+'} | Set-Content .\AssemblyInfo.cs
Remove-Item -path .\Properties\ -recurse -force
- Install PlayniteSDK package using
nuget
:
nuget restore -SolutionDirectory . -Verbosity normal
- Replace the csproj file content in your project folder for this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net4.6.2</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>DEBUG;NET462;TRACE</DefineConstants>
<DebugType>portable</DebugType>
</PropertyGroup>
<ItemGroup>
<ApplicationDefinition Remove="App.xaml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="PlayniteSDK" Version="6.2.0" />
</ItemGroup>
<ItemGroup>
<None Include="extension.yaml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<None Include="icon.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
- In VSCode, press
ctrl+shift+P
, type.NET: Generate Assets for Build and Debug
and pressEnter
- In VSCode, press
ctrl+shift+P
, typeTasks: Run Task > publish
and pressEnter
- Output folder should be in
.\bin\Debug\net4.6.2\publish
. Add the full path (including drive letter) to the external extensions list in Playnite, and restart it. - In Playnite, you should see your extension running in the Add-Ons window.
As soon as build VSCode debugger are not support x86 application debug and execution, but Playnite x86 officially only, You have to prepare x64 version of Playnite yourself to be able to debug. To do it you have:
- Install Windows PowerShell version 7.0.
- Open Powershell version 7.0 and in PlayniteSources call
.\build\build.ps1 Debug x64 c:\playnite
this will build binaries and move to c:\playnite. Please be aware that it may affect already existed Playnite installation at this location. - You have to download and replace x86 to x64 versions of SDL2.dll and SDL2_mixer.dll. Obtain it from official releases https://github.com/libsdl-org/SDL/releases and https://github.com/libsdl-org/SDL_mixer/releases
- Tune you .vscode/tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "build debug",
"command": "dotnet",
"type": "process",
"args": [
"build",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary;ForceNoAlign"
],
"problemMatcher": "$msCompile",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "build release",
"command": "dotnet",
"type": "process",
"args": [
"build",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary;ForceNoAlign",
"-c",
"Release"
],
"problemMatcher": "$msCompile"
},
{
"label": "pack",
"command": "C:\\Playnite\\Toolbox.exe",
"type": "process",
"args": [
"pack",
"${workspaceFolder}\\bin\\Release\\net4.6.2",
"${workspaceFolder}\\bin\\Package"
],
"problemMatcher": "$msCompile",
"dependsOn": [
"build release"
]
}
]
}
and .vscode/launch.json:
{
"configurations": [
{
"name": "Debug PlayniteSounds Desktop",
"type": "clr",
"request": "launch",
"preLaunchTask": "build debug",
"program": "C:\\Playnite\\Playnite.DesktopApp.exe",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "internalConsole",
"logging": {
"programOutput": true,
"moduleLoad": false,
"processExit": false
}
},
{
"name": "Debug PlayniteSounds Fullscreen",
"type": "clr",
"request": "launch",
"preLaunchTask": "build debug",
"program": "C:\\Playnite\\Playnite.FullscreenApp.exe",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "internalConsole",
"logging": {
"programOutput": true,
"moduleLoad": false,
"processExit": false
}
}
]
}
You can use something like XAML Studio to edit single XAML files graphically.