-
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
Support building for multiple RIDs, similar to how TargetFrameworks works #9795
Comments
if no |
I added support for that if you use my Extras package: Set that as the SDK attribute along with the version in the global.json (instructions are in the readme), then add a property in your csproj setting It will build each RID and put them into specific output folders. It will also define a RID-specific define so you can ifdef around it. |
cc @peterhuene |
@dasMulli assessment is correct and I think it is very confusing to use I think we would have to adopt something similar to @onovotny's extension to enable this, since it would be a breaking change for As I'm working on implicitly adding a RID to |
@peterhuene what I had to hack to make it work is pretty nasty, but not overly complex: It's nasty because it has to reach into NuGet's output resolution (to get the right dlls and put in the right output directory in the package) and also override a few other private targets. I'd prefer not to do that :) As part of the design, I also support conditional RID's per TFM, since some TFM's may have RID-specific implementations while others don't. I'd love to see this incorporated directly. |
I moved it to 3.0 and under your epic. We can check the state of things when some of your changes are in and make a decision on whether we want to enable exactly this or not and how. |
This would be a major feature to add. We won't be able to do it in the 3.0 release, so I'm moving it to the backlog. |
The scenario could be interesting for how things will change in ".NET 5".. No idea how/if TFMs are going to evolve but I could also easily see a world where we could do <PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<RuntimeIdentifiers>iOS12.0-arm64;iOS12.0-x64;android-arm;android-arm64;android-x64</RuntimeIdentifiers>
</PropertyGroup> or something similar instead of |
This is a valid scenario. I'd argue that on desktop platforms, it also makes sense to have, e.g. |
There are certain build scenarios where package restoration must be performed in a separate step from building. Some build systems intentionally cut network access after restoration for security reasons; all tasks requiring external resources have to be performed before this cut and then made locally available for any following tasks (such as |
Let's prioritize this feature, since GoReleaser also have it. My ultimate use case is to use this to build single file executable for each platform in Docker (ARM, Windows, Linux/Musl, etc). |
I think since .NET allows the RID in the TFM that users must really do that instead, then under the |
For anyone still looking for a solution, I found a really hacky work-around. <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Platforms>x64;x86</Platforms>
<OutDir>output/$(Configuration)/</OutDir>
<AssemblyName Condition="'$(Platform)' == 'x86'">$(MSBuildProjectName).x86</AssemblyName>
</PropertyGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Platform)' == 'x64'">
<MSBuild Projects="$(MSBuildProjectFile)" Properties="Platform=x86" />
</Target>
</Project> |
Steps to reproduce
Have project file
run
dotnet build
Expected behavior
Builds .dlls, that is the cross join between the RuntimeIdentifiers and TargetFrameworks
Actual behavior
Tries to build the any rid for each framework in TargetFrameworks but can't because the
any
rid is unbuildable on this project.Environment data
dotnet --info
output:.NET Core SDK (reflecting any global.json):
Version: 2.1.302
Commit: 9048955
Runtime Environment:
OS Name: debian
OS Version: 9
OS Platform: Linux
RID: debian.9-x64
Base Path: /usr/share/dotnet/sdk/2.1.302/
Host (useful for support):
Version: 2.1.2
Commit: 811c3ce6c0
.NET Core SDKs installed:
2.1.302 [/usr/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
@onovotny: I tried your MSBuild.Sdk.Extras version 1.6.30-preview and 1.7.1-preview; however while it can make a reference assembly just fine it doesn't seem to convince
dotnet build
ordotnet pack
to do the right thing with RuntimeIdentifiers. 1.6.40 seems to be brain-damaged and the builds bomb.dotnet /usr/share/dotnet/sdk/2.1.302/MSBuild.dll
doesn't work either.The text was updated successfully, but these errors were encountered: