-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dotnet-publish with --use-current-rid or --infer-rid option #10449
Comments
It would be awesome if this could be configured in the .csproj too |
@peterhuene can you help out here? |
@livarcocc as a feature for 5.0? |
That's what I had in mind, though I imagine we should spend some time figuring it out exactly. cc @KathleenDollard |
IMHO this is a reasonable request, the SDK already does some RID inferring, even for non-rid-specific builds, and generates a host in 3.0 |
For what its worth, the use case for me was that the codebase I was working with was being migrated from .Net Framework. It expected .exe files to be in certain locations. This meant that an rid had to be specified to get an actual executable file. On linux and mac, the executable was renamed to end in .exe However, I want it so that simply doing a dotnet build will produce an exe, as simply building and producing dlls breaks the code as it expects to have executables. Hence, specifying inferCurrentRID in the .csproj would be helpful, as it would force the code to output actual executable artifacts during a build and not just when publishing or manually specifying the RID Obviously hard coding the RID for a particular platform is not an option, as the code should be able to build and run on any os. |
+1 It's good to make explicit what rid the published artifacts are going to work on. Especially on Linux, where users may expect publish to mean source-build .NET Core will be producing artifacts which are likely to not be compatible with |
Did you try the 3.0 previews already? You should get a .exe for non RID-specific builds as well. Building / publishing for a specific RID and generating an apphost (.exe on windows, mach-o executable on macOS, ELF binary on linux) are not necessarily both necessary. The SDK is capable of emitting a host binary for the current RID even for framework-dependent deployments so you don't absolutely have to build a RID-specific application if you just need an .exe file for some tools. It should be default as of now and can be opted into using by adding The difference is that assets restored from NuGet are filtered for the target RID and you may end up with platform-specific native and/or managed libraries for that target RID. For example, you can add |
Sadly there is no way (@peterhuene / @nguerrera correct me if I'm wrong) to specify a RID for the app host generation without forcing NuGet to create a RID-specific package / asset graph and e.g. create a framework-dependent deployment with a convenience host for different platform. |
Initial Feature was added in 2020 but not documented here: dotnet/sdk#10449 We've added implicit RIDs here: dotnet/sdk#26143 And we've added interaction to toggle implicit RIDs off with UCR here: dotnet/sdk#28628 And we added the shorthand for ucr here: dotnet/sdk#27971 Needs to be duplicated for `dotnet publish` as well.
At present:
throws error:
which requires a fix like:
It is fairly a common usecase to publish an app for platform with same RID as host.
However, the error is good to keep it an explicit and conscious decision of user; instead of falling back to some default value.
Please add
--use-current-rid
or--infer-rid
option for automation and documentation convenience.This way user will still explicitly specify RID option, without supplying platform specific value.
The text was updated successfully, but these errors were encountered: