dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.66k stars 1.06k forks source link

How to author 'dotnet tool' packages that are CPU-architecture (or OS) specific? #24016

Open AArnott opened 2 years ago

AArnott commented 2 years ago

I build a few dotnet CLI tool packages, but I don't know what to do about tools that target specific CPU platforms. For example one of my tools has a native dependency so it's fundamentally locked to x64. But I am happy to target arm64 as well and bring those native dependencies with it. But can I do this in such a way that the tool package includes everything (x64 and arm64 binaries) and have the dotnet CLI tools just pick the right runtime binaries based on the OS architecture?

Similar question for targeting OSs: I can multi-target with net6.0-windows7;net6.0-linux etc, but unless the .targets that pack the tool take all the output and arrange it (considering both TFM and RID), it won't really do me any good.

baronfel commented 2 years ago

This is an area that's come up several times over the past couple months - both the ML.Net teams as well as power users like @clairernovotny have had similar questions. The answer so far has been 'the design of dotnet tools was cross-platform by default', but the platform as a whole is moving in ways that encourage broader use of platform-specific code so we should probably re-evaluate this stance.