How to make packages with runtime specific managed assembly? #14265
Unanswered
Akarinnnnn
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm authoring package with ref & runtimes folders, using nuspec and custom MSBuild target file. When I reference that package in testing project, assemblies under runtimes folder can't be loaded at runtime. And no complication errors emitted.
The main reason the project have to build different versions for different runtimes, is our native dependency have different names on different platform("steam_api" for 32bit and "steam_api64" for 64b). Next decision make things difficult is they are imported by P/Invoke, which requires literal library name.
Considering this open source project's major consumers is Unity developer, and history burden, we can't change from P/Invoke to other importing method easily. For Unity consumers their build product is targeting to a specified runtime, everything used to determine runtime is also provided at compile time, therefore require literal library names won't cause problem.
As for
PackageReference
consumers, we made a SDK style project to build NuGet package. But for creating an all-in-one package contains all variant,dotnet pack
didn't help. Such packages which have runtime specific assemblies have to use NuGet client and nuspec, and build variants manually.I want to know the correct method to create packages which have runtime specific assemblies.
Below is project code and result package.
Runtime error in test project(FileNotFoundException System can't find specified file):

Here is the result package produced by the instruction in project.
Result package Steamworks.NET.2025.4.23-d.nupkg.renamed.zip
And test project:
Windows x64 only Steamworks.NET.Tests.Packaged.zip
Other information:
This project first produce all assemblies by MSBuild target
BatchBuild
inBuildPackages.targets
. In this target it will build every possible version and copy them tobin\nuget\runtime
, then reference assembly and copy tobin\nuget\ref
. Next I use nuspec to generate package. Please tell me if any steps contains problem.Project code at ask point
nuspec
Beta Was this translation helpful? Give feedback.
All reactions