Skip to content

Conversation

@Akarinnnnn
Copy link
Contributor

Originally posted in #699. Achieved by register a dll resolve hook to default Assembly Load Context.

Dependencies to AssemblyLoadContext makes this change is not meaningful to any runtimes other than .NET(Core). So these changes are separated into a different folder to keep old version unchanged like .NET Framework 4.0 does.

Acheived by register a dll resolve hook to default Assembly Load Context.
Changes are seperated into a different folder to keep old version unchanged.
@Akarinnnnn
Copy link
Contributor Author

Akarinnnnn commented Aug 18, 2025

Meta file of Steam.cs need to be regenerated. Not needed since no file is added.

Copy link

@Chicken-Bones Chicken-Bones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good implementation, it works perfectly for our case, but I've left a note on how to reduce potential breakage even further. I also tested the nuget package. Thankyou

@Chicken-Bones
Copy link

Please let me know when I can find this on your mainstream NuGet :)

@Akarinnnnn
Copy link
Contributor Author

I'd like to make correct steam binaries being distributed by Any CPU NuGet package, 1 PR within 10 lines estimated.

@Chicken-Bones
Copy link

Any update on this one?

@Akarinnnnn
Copy link
Contributor Author

Any update on this one?

Steam native binaries are packed into Steamworks.NET.AnyCPU, version 2025.162.1. Changes to project files are pushed to another branch called standalone-v3.

@Akarinnnnn
Copy link
Contributor Author

Akarinnnnn commented Sep 10, 2025 via email

@Akarinnnnn
Copy link
Contributor Author

Akarinnnnn commented Sep 19, 2025 via email

@Chicken-Bones
Copy link

Chicken-Bones commented Oct 2, 2025

#747

Packsize.value is being compiled as 4, but unfortunately windows has to go and be special.

I'm not sure if there's a way to ship two different dlls based on OS via nuget. Such a pain...

image

@Akarinnnnn
Copy link
Contributor Author

Akarinnnnn commented Oct 2, 2025 via email

@Chicken-Bones
Copy link

Sinply removing it probably won't work, because it's required to be 4 on osx and linux, despite the default abi for x64 and arm64 on those platforms being 8

@Akarinnnnn
Copy link
Contributor Author

Akarinnnnn commented Oct 2, 2025 via email

@Chicken-Bones
Copy link

Sounds like a viable approach. Shouldn't be too hard. Will make for the smallest package.

Only easier way would be if you know how to ship different managed assemblies for windows and non-windows in a nuget package...

@Chicken-Bones
Copy link

Chicken-Bones commented Oct 2, 2025

I have managed to deploy a workaround where I replace the Steamworks.NET.dll file on disk in our deployment with a build I made containing Packsize = 8 on windows for now to reduce urgency. Let me know if I can help more with a proper fix :)

@Akarinnnnn
Copy link
Contributor Author

Akarinnnnn commented Oct 2, 2025

Only easier way would be if you know how to ship different managed assemblies for windows and non-windows in a nuget package...

In my design, generated custom marshaller will remain both alignment at runtime, but only one will be chosen. By keeping them all we can still building single unified assembly. But... we still went to this place: make big changes to codegen and add massive amount of custom marshalling code.

It is huge I think, after all this is related to all callback structs(even some parameters maybe).

@Chicken-Bones
Copy link

For callbacks, replacing Marshal.PtrToStructure isn't too bad, but custom marshalling is a sad place to go to for types in extern definitions.

Based on https://learn.microsoft.com/en-us/nuget/create-packages/native-files-in-net-packages it should be possible to make NuGet package structure like:

lib/net8.0/Steamworks.NET.dll
lib/net8.0/Steamworks.NET.pdb
runtimes/linux-x64/native/libsteam_api.so
runtimes/osx/native/libsteam_api.dylib
runtimes/win/lib/net8.0/Steamworks.NET.dll
runtimes/win/lib/net8.0/Steamworks.NET.pdb
runtimes/win-x64/native/steam_api64.dll
runtimes/win-x86/native/steam_api.dll

Where runtimes/win/lib/net8.0/Steamworks.NET.dll has Packsize = 8 and lib/net8.0/Steamworks.NET.dll has Packsize = 4

@Akarinnnnn
Copy link
Contributor Author

Akarinnnnn commented Oct 2, 2025

Only easier way would be if you know how to ship different managed assemblies for windows and non-windows in a nuget package...

it should be possible to make NuGet package structure like

If we want to ship different assemblies for different platform, it's possible, and we already achieved this goal, But we have to manually write MSBuild script and NuGet specification file, then execute them by some long and complex commands, which is not easy to type correct in once. This hard way is probably how they build package Steamworks.NET. I don't know how someone use my buggy workflow to build so much package versions, thanks to them.

Return to our subject, when I created this any CPU variant, I decided to simplify packaging workflow into one command: dotnet pack --version $(Version). A simpler and robust way.

To achieve this goal, we must discard manually written .nuspec. In result, we can no longer specify where to put our main output(DLL) inside packages. This brings an another bad news: Even if we managed to built all alignment variant, we can't use them for such pack workflow. After some investigation, I found dotnet pack can't build all configurations, it uses single one form start to end, typically Release.

But dotnet pack have another advantages: It will build for all target frameworks and place their output correctly. It will be important when we want to start support more than one target framework.

I have to say, through we can inherit old NuGet workflow from Standalone2.0, this is a chance to embrace revolution. Please let me know which path should we continue. React ❤️ for cross platform dotnet pack --version 2025.162.3, 👀 for inherit dotnet build -t:BatchBuild Steamworks.NET.Standard.sln -p:Version=2025.162.3 then windows only nuget.exe pack Steamworks.NET.nuspec -OutputDirectory bin\ -Version 2025.162.3. @Chicken-Bones @rlabrecque.

Anymore, Packsize.value should never be a public const for any CPU variant(I think other version too). Either hide it or turn it to static readonly as #675 said, we should do some act.

@Chicken-Bones
Copy link

Regrettably, I vote for custom marshalling. Maybe with clever sourcegen we can produce pack=4 variants of the structures only when pack size actually makes a difference to the layout. Then all native methods which rely on these will need 2 definitions, and a wrapper to type convert depending on platform

@Akarinnnnn
Copy link
Contributor Author

I've try to fix by wrapper struct, but I met some problems. Callback retrieval is mostly fixed I think, but those struct directly passed into a interface parameter is still a problem, I can't intercept it's marshal process. We may still have to go old way: ship different assemblies. Here is the fix proposal Akarinnnn#1 .

ryan-linehan and others added 10 commits October 28, 2025 22:50
…CPU (#2)

Adds a simple workflow for packing the Steamworks.NET.AnyCPU nuget
package and publishing it to nuget.org. Currently only run on manual run
of the workflow.

The workflow uses nuget.org's newer [trusted publishing
](https://learn.microsoft.com/en-us/nuget/nuget-org/trusted-publishing)
so there is a step for the owner of the nuget package on nuget.org to do
as well as the action variable of NUGET_USER. Its not a secret but this
allows another to use the action without it hard coded. Ideally, we get
to be able to publish a beta branch through the workflow to make sure it
works.
Merge changes from upstream to keep us up to date.

It's here because #3 merged into a legacy branch master.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants