You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that when building .NET 5 projects on Windows and using one of the values x86, x64, arm (or ARM) for Platform (MSBuild property), the PlatformTarget property seems to automatically be set by the SDK to the Platform value. However, when using arm64 (or ARM64), it doesn't seem to get set, and it seems to assume AnyCPU (so the copied apphost EXE is not necessarily of the specified architecture).
For example:
Install .NET SDK 5.0.102 (x64) on Windows 10 Version 20H2 x64
Create a new .NET 5 project with dotnet new console
Notice that when Platform is arm64, PlatformTarget is not set. This seems to cause the SDK using the apphost with the SDK architecture (x64) instead of the specified platform (arm64). When we set the PlatformTarget manually to arm64, then the arm64 apphost is used.
This also seems to be the case when specifying RuntimeIdentifiers, where for win-arm64 the PlatformTarget is AnyCPU but e.g. for win-x64 it is x64.
In Microsoft.NET.Sdk.props, I can see the following condition that sets the PlatformTarget based on Platform:
Hi!
I noticed that when building .NET 5 projects on Windows and using one of the values
x86
,x64
,arm
(orARM
) forPlatform
(MSBuild property), thePlatformTarget
property seems to automatically be set by the SDK to thePlatform
value. However, when usingarm64
(orARM64
), it doesn't seem to get set, and it seems to assumeAnyCPU
(so the copied apphost EXE is not necessarily of the specified architecture).For example:
dotnet new console
project.csproj
:dotnet build -p:Platform=x64
dotnet build -p:Platform=x86
dotnet build -p:Platform=arm
dotnet build -p:Platform=arm64
It produces the following output from the target:
Platform: 'x64', PlatformTarget: 'x64', RID: ''
Platform: 'x86', PlatformTarget: 'x86', RID: ''
Platform: 'arm', PlatformTarget: 'ARM', RID: ''
Platform: 'arm64', PlatformTarget: '', RID: ''
Notice that when
Platform
isarm64
,PlatformTarget
is not set. This seems to cause the SDK using the apphost with the SDK architecture (x64) instead of the specified platform (arm64). When we set thePlatformTarget
manually toarm64
, then the arm64 apphost is used.This also seems to be the case when specifying RuntimeIdentifiers, where for
win-arm64
thePlatformTarget
isAnyCPU
but e.g. forwin-x64
it isx64
.In
Microsoft.NET.Sdk.props
, I can see the following condition that sets thePlatformTarget
based onPlatform
:sdk/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.props
Lines 61 to 73 in 4ad1d84
Notice that it checks
Platform
forx86
,x64
, andARM
, but not forARM64
.Is this intended behavior?
Thank you!
The text was updated successfully, but these errors were encountered: