Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>

<PropertyGroup Label="CalculateArch">
<BuildArchitecture Condition="'$(BuildArchitecture)' == ''">$([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant())</BuildArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' AND ('$(BuildArchitecture)' == 'arm64' OR '$(BuildArchitecture)' == 's390x' OR '$(BuildArchitecture)' == 'ppc64le' OR '$(BuildArchitecture)' == 'loongarch64')">$(BuildArchitecture)</TargetArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == ''">x64</TargetArchitecture>
</PropertyGroup>

<!-- Host and target OS detection.
Uses full OS names (windows, linux, osx, freebsd, etc.) matching the VMR convention.
See https://github.com/dotnet/dotnet/blob/main/docs/VMR-Controls.md#output-controls -->
<PropertyGroup Label="CalculateTargetOS">
<HostOS Condition="'$(HostOS)' == '' AND $([MSBuild]::IsOSPlatform('WINDOWS'))">windows</HostOS>
<HostOS Condition="'$(HostOS)' == '' AND $([MSBuild]::IsOSPlatform('OSX'))">osx</HostOS>
<HostOS Condition="'$(HostOS)' == '' AND $([MSBuild]::IsOSPlatform('FREEBSD'))">freebsd</HostOS>
<HostOS Condition="'$(HostOS)' == '' AND $([MSBuild]::IsOSPlatform('OPENBSD'))">openbsd</HostOS>
<HostOS Condition="'$(HostOS)' == '' AND $([MSBuild]::IsOSPlatform('ILLUMOS'))">illumos</HostOS>
<HostOS Condition="'$(HostOS)' == '' AND $([MSBuild]::IsOSPlatform('SOLARIS'))">solaris</HostOS>
<HostOS Condition="'$(HostOS)' == '' AND $([MSBuild]::IsOSPlatform('HAIKU'))">haiku</HostOS>
<HostOS Condition="'$(HostOS)' == '' AND $([MSBuild]::IsOSPlatform('LINUX'))">linux</HostOS>

<!-- TargetOS defaults to HostOS; overridable via /p:TargetOS from build scripts or VMR. -->
<TargetOS Condition="'$(TargetOS)' == ''">$(HostOS)</TargetOS>
</PropertyGroup>

<Import Project="Sdk.props" Sdk="Microsoft.DotNet.Arcade.Sdk" />

<PropertyGroup Condition="'$(CopyrightNetFoundation)' != ''">
Expand Down Expand Up @@ -67,6 +91,8 @@ ates https://learn.microsoft.com/en-gb/dotnet/fundamentals/syslib-diagnostics/sy
version numbers. This is ok in that context, since VMR-produced MSBuild packages won't
be published. -->
<NoWarn Condition="'$(DotNetBuild)' == 'true'">$(NoWarn);NU5104;</NoWarn>

<DefineConstants Condition="'$(TargetOS)' == 'windows'">$(DefineConstants);TARGET_WINDOWS</DefineConstants>
</PropertyGroup>

<PropertyGroup>
Expand Down
10 changes: 10 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,14 @@
Condition="Exists('$(_PackageFolderInGlobalPackages)')" />
</Target>

<!-- Diagnostic target for verifying platform property resolution -->
<Target Name="ShowPlatformProperties"
BeforeTargets="Build"
Condition="'$(ShowPlatformProperties)' == 'true'">
<Message Importance="high" Text="HostOS = $(HostOS)" />
<Message Importance="high" Text="TargetOS = $(TargetOS)" />
<Message Importance="high" Text="BuildArchitecture = $(BuildArchitecture)" />
<Message Importance="high" Text="TargetArchitecture = $(TargetArchitecture)" />
</Target>
Comment on lines +61 to +69
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually just use the inbuilt -getproperty command to get these property if we need them or look at a binlog.


</Project>
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

<!-- Target frameworks for Exe and unit test projects (ie projects with runtime output) -->
<RuntimeOutputTargetFrameworks>$(LatestDotNetCoreForMSBuild)</RuntimeOutputTargetFrameworks>
<RuntimeOutputTargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(FullFrameworkTFM);$(RuntimeOutputTargetFrameworks)</RuntimeOutputTargetFrameworks>
<RuntimeOutputTargetFrameworks Condition="'$(TargetOS)' == 'windows'">$(FullFrameworkTFM);$(RuntimeOutputTargetFrameworks)</RuntimeOutputTargetFrameworks>

<!-- Don't automatically append target framework to output path, since we want to put the Platform Target beforehand, if it's not AnyCPU -->
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
Expand Down
Loading