This works with Microsoft preview9, but not with source-build preview9:
$ dotnet new console -o console
$ cd console
$ dotnet restore -r linux-x64
$ dotnet publish -r linux-x64 --self-contained false /p:PublishReadyToRun=true
Microsoft (R) Build Engine version 16.3.0-preview-19426-01+faf5e5d75 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 23.79 ms for /tmp/console/console.csproj.
You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview
console -> /tmp/console/bin/Debug/netcoreapp3.0/linux-x64/console.dll
/usr/lib64/dotnet/sdk/3.0.100-preview9-014004/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(252,5): error NETSDK1095: Optimizing assemblies for performance is not supported for the selected target platform or architecture. Please verify you are using a supported runtime identifier, or set the PublishReadyToRun property to false. [/tmp/console/console.csproj]
CC @omajid @dagood @crummel
diag log:
Using "PrepareForReadyToRunCompilation" task from assembly "/usr/lib64/dotnet/sdk/3.0.100-preview9-014004/Sdks/Microsoft.NET.Sdk/targets/../tools/netcoreapp2.1/Microsoft.NET.Build.Tasks.dll".
Task "PrepareForReadyToRunCompilation" (TaskId:84)
Task Parameter:
RuntimePacks=
Microsoft.NETCore.App.Runtime.linux-x64
FrameworkName=Microsoft.NETCore.App
IsTrimmable=true
OriginalItemSpec=Microsoft.NETCore.App.Runtime.linux-x64
PackageDirectory=/opt/app-root/.nuget/packages/microsoft.netcore.app.runtime.linux-x64/3.0.0-preview9-19423-09
PackageName=Microsoft.NETCore.App.Runtime.linux-x64
PackageVersion=3.0.0-preview9-19423-09
RuntimeIdentifier=linux-x64
Microsoft.AspNetCore.App.Runtime.linux-x64
FrameworkName=Microsoft.AspNetCore.App
IsTrimmable=
OriginalItemSpec=Microsoft.AspNetCore.App.Runtime.linux-x64
PackageDirectory=/opt/app-root/.nuget/packages/microsoft.aspnetcore.app.runtime.linux-x64/3.0.0-preview9.19424.4
PackageName=Microsoft.AspNetCore.App.Runtime.linux-x64
PackageVersion=3.0.0-preview9.19424.4
RuntimeIdentifier=linux-x64 (TaskId:84)
Task Parameter:RuntimeGraphPath=/usr/lib64/dotnet/sdk/3.0.100-preview9-014004/RuntimeIdentifierGraph.json (TaskId:84)
Task Parameter:
KnownFrameworkReferences=
Microsoft.NETCore.App
DefaultRuntimeFrameworkVersion=3.0.0-preview9-19423-09
IsTrimmable=true
LatestRuntimeFrameworkVersion=3.0.0-preview9-19423-09
RuntimeFrameworkName=Microsoft.NETCore.App
RuntimePackNamePatterns=Microsoft.NETCore.App.Runtime.**RID**
RuntimePackRuntimeIdentifiers=linux-arm;linux-arm64;linux-musl-arm64;linux-musl-x64;linux-x64;osx-x64;rhel.6-x64;rhel.8-x64;tizen.4.0.0-armel;tizen.5.0.0-armel;win-arm;win-arm64;win-x64;win-x86
TargetFramework=netcoreapp3.0
TargetingPackName=Microsoft.NETCore.App.Ref
TargetingPackVersion=3.0.0-preview9-19423-09
Microsoft.WindowsDesktop.App
DefaultRuntimeFrameworkVersion=3.0.0-preview9-19423-09
IsWindowsOnly=true
LatestRuntimeFrameworkVersion=3.0.0-preview9-19423-09
RuntimeFrameworkName=Microsoft.WindowsDesktop.App
RuntimePackNamePatterns=Microsoft.WindowsDesktop.App.Runtime.**RID**
RuntimePackRuntimeIdentifiers=win-x64;win-x86
TargetFramework=netcoreapp3.0
TargetingPackName=Microsoft.WindowsDesktop.App.Ref
TargetingPackVersion=3.0.0-preview9-19423-09
Microsoft.WindowsDesktop.App.WPF
DefaultRuntimeFrameworkVersion=3.0.0-preview9-19423-09
IsWindowsOnly=true
LatestRuntimeFrameworkVersion=3.0.0-preview9-19423-09
Profile=WPF
RuntimeFrameworkName=Microsoft.WindowsDesktop.App
RuntimePackNamePatterns=Microsoft.WindowsDesktop.App.Runtime.**RID**
RuntimePackRuntimeIdentifiers=win-x64;win-x86
TargetFramework=netcoreapp3.0
TargetingPackName=Microsoft.WindowsDesktop.App.Ref
TargetingPackVersion=3.0.0-preview9-19423-09
Microsoft.WindowsDesktop.App.WindowsForms
DefaultRuntimeFrameworkVersion=3.0.0-preview9-19423-09
IsWindowsOnly=true
LatestRuntimeFrameworkVersion=3.0.0-preview9-19423-09
Profile=WindowsForms
RuntimeFrameworkName=Microsoft.WindowsDesktop.App
RuntimePackNamePatterns=Microsoft.WindowsDesktop.App.Runtime.**RID**
RuntimePackRuntimeIdentifiers=win-x64;win-x86
TargetFramework=netcoreapp3.0
TargetingPackName=Microsoft.WindowsDesktop.App.Ref
TargetingPackVersion=3.0.0-preview9-19423-09
Microsoft.AspNetCore.App
DefaultRuntimeFrameworkVersion=3.0.0-preview9.19424.4
LatestRuntimeFrameworkVersion=3.0.0-preview9.19424.4
RuntimeFrameworkName=Microsoft.AspNetCore.App
RuntimePackNamePatterns=Microsoft.AspNetCore.App.Runtime.**RID**
RuntimePackRuntimeIdentifiers=win-x64;win-x86;win-arm;osx-x64;linux-musl-x64;linux-musl-arm64;linux-x64;linux-arm;linux-arm64
TargetFramework=netcoreapp3.0
TargetingPackName=Microsoft.AspNetCore.App.Ref
TargetingPackVersion=3.0.0-preview9.19424.4
NETStandard.Library
TargetFramework=netstandard2.1
TargetingPackName=NETStandard.Library.Ref
TargetingPackVersion=2.1.0-preview9-19423-09 (TaskId:84)
Task Parameter:NETCoreSdkRuntimeIdentifier=rhel.8-x64 (TaskId:84)
Task Parameter:OutputPath=obj/Debug/netcoreapp3.0/linux-x64/R2R (TaskId:84)
Task Parameter:
FilesToPublish=
/tmp/console/obj/Debug/netcoreapp3.0/linux-x64/console
CopyToPublishDirectory=Always
IsKeyOutput=True
RelativePath=console
TargetPath=console
obj/Debug/netcoreapp3.0/linux-x64/console.dll
CopyToPublishDirectory=PreserveNewest
RelativePath=console.dll
/tmp/console/bin/Debug/netcoreapp3.0/linux-x64/console.deps.json
CopyToPublishDirectory=PreserveNewest
RelativePath=console.deps.json
/tmp/console/bin/Debug/netcoreapp3.0/linux-x64/console.runtimeconfig.json
CopyToPublishDirectory=PreserveNewest
RelativePath=console.runtimeconfig.json
obj/Debug/netcoreapp3.0/linux-x64/console.pdb
CopyToPublishDirectory=PreserveNewest
ExcludeFromSingleFile=true
RelativePath=console.pdb (TaskId:84)
Task Parameter:IncludeSymbolsInSingleFile=False (TaskId:84)
13:58:40.912 1:7>/usr/lib64/dotnet/sdk/3.0.100-preview9-014004/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(252,5): error NETSDK1095: Optimizing assemblies for performance is not supported for the selected target platform or architecture. Please verify you are using a supported runtime identifier, or set the PublishReadyToRun property to false. [/tmp/console/console.csproj]
It seems https://github.com/dotnet/source-build/pull/1231 is also fixing this.
I guess PrepareForReadyToRunCompilation is making a false assumption that because rhel.8 is in RuntimePackRuntimeIdentifiers, the crossgen for linux-x64 won't work. See https://github.com/dotnet/sdk/blob/752d6e5f4d02c81b7ff32c1bde6fa4d3f033c881/src/Tasks/Microsoft.NET.Build.Tasks/PrepareForReadyToRunCompilation.cs#L81-L86.
Waiting to see if #1231 fixes this.
Still not fixed in 3.0.0 (linux-arm target)
@gpomykala if you are using Microsoft .NET Core binaries, please report an issue in a different repo, like: https://github.com/dotnet/core.
It looks like https://github.com/dotnet/source-build/pull/1231 didn't fix this issue. Any idea what's going on here @nguerrera or @dsplaisted?
I'm looking at related broken assumption in R2R in 3.1. I'll see if I can figure this out. By any chance can someone provide me with a machine I can SSH to that has the source built dotnet on PATH and ready to test?
It looks like #1231 didn't fix this issue.
Changing RuntimePackRuntimeIdentifiers did work for me with source-build preview9.
So either https://github.com/dotnet/source-build/pull/1231 isn't properly updating the RuntimePackRuntimeIdentifiers. Or something has changed since preview9.
@crummel can you check RuntimePackRuntimeIdentifiers (see https://github.com/dotnet/source-build/pull/1231#issuecomment-532184641)?
Source-built 3.0 SDK:
linux-arm;linux-arm64;linux-musl-arm64;linux-musl-x64;linux-x64;osx-x64;rhel.6-x64;rhel.7-x64;tizen.4.0.0-armel;tizen.5.0.0-armel;win-arm;win-arm64;win-x64;win-x86
So the difference from that change is the additional rhel.7-x64 RID. That doesn't seem like it would affect Debian or CentOS though, we're seeing failures there too.
Are you sure that it doesn't change to debian.x and centos.x when source-built on those platforms? The extra <build platform rid> is the exact problem that https://github.com/dotnet/source-build/pull/1231 was trying to solve. 馃槙
Oh, that was dumb. Yeah, confirmed on my CentOS build as well.
Was the patch applied?
Oh, I think that's what happened. The 3.0 update PR didn't have your change in it and that's what we tested on, not the merged PR. I'll regenerate a tarball and we'll retest locally, but I'm betting that's all it'll take to fix the issue.
To be precise it does not work in cross-compilation scenario win-x64->linux-arm. It did work in linux-x64->linux-arm (i learned about that limitation elsewhere)
@gpomykala there are some limitations, see https://docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-3-0#cross-platformarchitecture-restrictions.
The new tarball tested out fine and we've tagged the release.
Most helpful comment
Oh, I think that's what happened. The 3.0 update PR didn't have your change in it and that's what we tested on, not the merged PR. I'll regenerate a tarball and we'll retest locally, but I'm betting that's all it'll take to fix the issue.