Skip to content

Commit

Permalink
[bindings] refactor NuGet packages
Browse files Browse the repository at this point in the history
Declare .NET native dependencies per-plaftorm in `runtime.json`.

Helps consumer apps only download and use the relevant native package for the desired OS/arch.

Apps which need the native dependencies in their build output dir should consider https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#enabledynamicloading or, alternatively, rely on `dotnet publish -r <RID>`.
  • Loading branch information
nil4 committed Feb 4, 2025
1 parent 1e26230 commit 7c3fa9b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,13 @@
<tags>RoyalApps RoyalVNCKit VNC .NET</tags>
<repository type="git" url="https://github.com/royalapplications/royalvnc.git" commit="$NUGET_GIT_COMMIT$" />
<dependencies>
<group targetFramework="net9.0">
<dependency id="RoyalApps.RoyalVNCKit.native.linux-arm64" version="$NUGET_VERSION$" />
<dependency id="RoyalApps.RoyalVNCKit.native.linux-x64" version="$NUGET_VERSION$" />
<dependency id="RoyalApps.RoyalVNCKit.native.osx" version="$NUGET_VERSION$" />
<dependency id="RoyalApps.RoyalVNCKit.native.win-arm64" version="$NUGET_VERSION$" />
<dependency id="RoyalApps.RoyalVNCKit.native.win-x64" version="$NUGET_VERSION$" />
</group>
<group targetFramework="net9.0" />
</dependencies>
</metadata>
<files>
<file src="README.md" target="/README.md" />
<file src="..\RoyalApps_1024.png" target="/RoyalApps_1024.png" />
<file src="bin\Release\RoyalApps.RoyalVNCKit.dll" target="/lib/net9.0/RoyalApps.RoyalVNCKit.dll" />
<file src="bin\Release\runtime.json" target="/runtime.json" />
</files>
</package>
29 changes: 29 additions & 0 deletions Bindings/dotnet/RoyalApps.RoyalVNCKit/nuget/runtime.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"runtimes": {
"linux-arm64": {
"RoyalApps.RoyalVNCKit": {
"RoyalApps.RoyalVNCKit.native.linux-arm64": "v"
}
},
"linux-x64": {
"RoyalApps.RoyalVNCKit": {
"RoyalApps.RoyalVNCKit.native.linux-x64": "v"
}
},
"osx": {
"RoyalApps.RoyalVNCKit": {
"RoyalApps.RoyalVNCKit.native.osx": "v"
}
},
"win-arm64": {
"RoyalApps.RoyalVNCKit": {
"RoyalApps.RoyalVNCKit.native.win-arm64": "v"
}
},
"win-x64": {
"RoyalApps.RoyalVNCKit": {
"RoyalApps.RoyalVNCKit.native.win-x64": "v"
}
}
}
}
4 changes: 4 additions & 0 deletions Bindings/dotnet/nuget-pack-dotnet.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ $PROJECT_DIR = Join-Path $REPO_ROOT 'Bindings/dotnet/RoyalApps.RoyalVNCKit' -Res

exec { dotnet build --configuration Release "-p:Version=${NUGET_VERSION}" $PROJECT_DIR }

$template = Get-Content "${PROJECT_DIR}/nuget/runtime.template.json" -Encoding utf8 -Raw
$template.Replace('"v"', "`"${NUGET_VERSION}`"") `
| Set-Content "${PROJECT_DIR}/bin/Release/runtime.json" -Encoding utf8 -Force -NoNewline

Write-Host 'Creating RoyalApps.RoyalVNCKit NuGet package'

exec {
Expand Down

0 comments on commit 7c3fa9b

Please sign in to comment.