Skip to content

Commit fdb38b2

Browse files
committed
Fix build against musl
1 parent 519f6dc commit fdb38b2

File tree

6 files changed

+55
-1
lines changed

6 files changed

+55
-1
lines changed

src/SourceBuild/tarball/content/Directory.Build.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@
171171
</PropertyGroup>
172172

173173
<PropertyGroup>
174+
<OSPlatformIsMusl Condition="$(OSPlatformIsMuslCheck) == '0'">true</OSPlatformIsMusl>
175+
<OSPlatformIsMusl Condition="$(OSPlatformIsMusl) == ''">false</OSPlatformIsMusl>
176+
174177
<TargetRid Condition="'$(TargetRid)' == ''">$([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier)</TargetRid>
175178

176179
<TargetOS Condition="'$(TargetOS)' == '' AND $([MSBuild]::IsOSPlatform('WINDOWS'))">Windows_NT</TargetOS>
@@ -183,6 +186,7 @@
183186
<TargetRid Condition="'$(TargetOS)' == 'FreeBSD'">freebsd-$(Platform)</TargetRid>
184187
<TargetRid Condition="'$(TargetOS)' == 'OSX'">osx-$(Platform)</TargetRid>
185188
<TargetRid Condition="'$(TargetOS)' == 'Linux'">linux-$(Platform)</TargetRid>
189+
<TargetRid Condition="'$(TargetOS)' == 'Linux' AND '$(OSPlatformIsMusl)' == 'true'">linux-musl-$(Platform)</TargetRid>
186190
<TargetRid Condition="'$(TargetOS)' == 'Windows_NT'">win-$(Platform)</TargetRid>
187191
</PropertyGroup>
188192

src/SourceBuild/tarball/content/Directory.Build.targets

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
</ItemGroup>
1111
</Target>
1212

13+
<Target Name="GetOSPlatformIsMuslCheck"
14+
BeforeTargets="CollectPackageReferences">
15+
<Exec IgnoreExitCode="true" Command="ldd --version 2&gt;&amp;1 | grep -q musl">
16+
<Output TaskParameter="ExitCode" PropertyName="OSPlatformIsMuslCheck" />
17+
</Exec>
18+
</Target>
19+
1320
<Import Condition="'$(SkipArcadeSdkImport)' != 'true'" Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
1421

1522
</Project>

src/SourceBuild/tarball/content/repos/aspnetcore.proj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
<!-- https://github.com/dotnet/sdk/pull/20136 has not flowed into our bootstrap SDK yet, which causes file-in-use issues in ASP.NET
1616
due to an interaction with the RemoveSharedFrameworkDependencies task. disable package validation until this is fixed. -->
1717
<BuildCommandArgs>$(BuildCommandArgs) /p:EnablePackageValidation=false</BuildCommandArgs>
18+
<!-- below is temporary fix till https://github.com/dotnet/aspnetcore/issues/39822 is addressed -->
19+
<BuildCommandArgs Condition="'$(OSPlatformIsMusl)' == 'true'">$(BuildCommandArgs) --os-name linux-musl</BuildCommandArgs>
1820
<BuildCommand>$(ProjectDirectory)\eng\build$(ShellExtension) $(BuildCommandArgs)</BuildCommand>
1921

2022
<LogVerbosityOptOut>true</LogVerbosityOptOut>

src/SourceBuild/tarball/content/repos/installer.proj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
<BuildCommandArgs Condition="'$(TargetOS)' == 'Linux'">$(BuildCommandArgs) /p:Rid=$(TargetRid)</BuildCommandArgs>
2626
<BuildCommandArgs>$(BuildCommandArgs) /p:DOTNET_INSTALL_DIR=$(DotNetCliToolDir)</BuildCommandArgs>
2727

28-
<BuildCommandArgs Condition="'$(TargetOS)' == 'Linux'">$(BuildCommandArgs) /p:AspNetCoreSharedFxInstallerRid=linux-$(Platform)</BuildCommandArgs>
28+
<BuildCommandArgs Condition="'$(TargetOS)' == 'Linux' AND '$(OSPlatformIsMusl)' == 'false'">$(BuildCommandArgs) /p:AspNetCoreSharedFxInstallerRid=linux-$(Platform)</BuildCommandArgs>
29+
<BuildCommandArgs Condition="'$(TargetOS)' == 'Linux' AND '$(OSPlatformIsMusl)' == 'true'">$(BuildCommandArgs) /p:AspNetCoreSharedFxInstallerRid=linux-musl-$(Platform)</BuildCommandArgs>
2930
<!-- core-sdk always wants to build portable on OSX and FreeBSD -->
3031
<BuildCommandArgs Condition="'$(TargetOS)' == 'FreeBSD'">$(BuildCommandArgs) /p:CoreSetupRid=freebsd-x64 /p:PortableBuild=true</BuildCommandArgs>
3132
<BuildCommandArgs Condition="'$(TargetOS)' == 'OSX'">$(BuildCommandArgs) /p:CoreSetupRid=osx-x64</BuildCommandArgs>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
From 451aa3e9544b0214d0e8e844c27af3847f5bf391 Mon Sep 17 00:00:00 2001
2+
From: Antoine Martin <dev@ayakael.net>
3+
Date: Fri, 18 Feb 2022 05:14:39 +0000
4+
Subject: [PATCH 1/1] musl build fix
5+
6+
Line causes build of aspnetcore on arm to look for linux version of
7+
CrossGen2 rather than linux-musl. This removes the line so that
8+
BuildOsName is pulled from TargetOsName as expected
9+
10+
Will be fixed once https://github.com/dotnet/aspnetcore/issues/37400
11+
is addressed.
12+
13+
---
14+
.../App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj | 1 -
15+
1 file changed, 1 deletion(-)
16+
17+
diff --git a/src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj b/src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj
18+
index aeb3c08f13..380fc5fbac 100644
19+
--- a/src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj
20+
+++ b/src/Framework/App.Runtime/src/Microsoft.AspNetCore.App.Runtime.csproj
21+
@@ -104,7 +104,6 @@ This package is an internal implementation of the .NET Core SDK and is not meant
22+
Special case the crossgen2 package reference on Windows to avoid the x86 package when building in Visual Studio.
23+
-->
24+
<BuildOsName>$(TargetOsName)</BuildOsName>
25+
- <BuildOsName Condition="'$(TargetOsName)' == 'linux-musl' and '$(TargetArchitecture)'!='x64'">linux</BuildOsName>
26+
<Crossgen2BuildArchitecture Condition=" '$(BuildOsName)' == 'win' ">x64</Crossgen2BuildArchitecture>
27+
<Crossgen2BuildArchitecture Condition=" '$(Crossgen2BuildArchitecture)' == '' ">$(BuildArchitecture)</Crossgen2BuildArchitecture>
28+
<Crossgen2PackageRootVariableName>PkgMicrosoft_NETCore_App_Crossgen2_$(BuildOsName)-$(Crossgen2BuildArchitecture)</Crossgen2PackageRootVariableName>
29+
--
30+
2.34.1
31+

src/redist/targets/GetRuntimeInformation.targets

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
<Project>
22
<Target Name="GetCurrentRuntimeInformation">
3+
<Exec IgnoreExitCode="true" Command="ldd --version 2&gt;&amp;1 | grep -q musl">
4+
<Output TaskParameter="ExitCode" PropertyName="OSPlatformIsMuslCheck" />
5+
</Exec>
6+
37
<PropertyGroup>
8+
<OSPlatformIsMusl Condition="$(OSPlatformIsMuslCheck) == '0'">true</OSPlatformIsMusl>
9+
<OSPlatformIsMusl Condition="$(OSPlatformIsMusl) == ''">false</OSPlatformIsMusl>
10+
411
<HostRid Condition="'$(HostRid)' == '' and '$(MSBuildRuntimeType)' == 'core'">$([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier)</HostRid>
512
<HostRid Condition="'$(HostRid)' == '' and '$(MSBuildRuntimeType)' != 'core'">win-$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLowerInvariant)</HostRid>
613

@@ -9,6 +16,8 @@
916
<HostOSName Condition=" '$(HostOSName)' == '' AND $([MSBuild]::IsOSPlatform('OSX')) ">osx</HostOSName>
1017
<HostOSName Condition=" '$(HostOSName)' == '' AND $([MSBuild]::IsOSPlatform('FREEBSD')) ">freebsd</HostOSName>
1118
<HostOSName Condition=" '$(HostOSName)' == '' AND '$(IsLinux)' == 'True' ">linux</HostOSName>
19+
<!-- If platform is musl based, adds information to HostOSName -->
20+
<HostOSName Condition="$(OSPlatformIsMusl) == 'true'">$(HostOSName)-musl</HostOSName>
1221

1322
<OSName Condition=" '$(OSName)' == '' ">$(HostOSName)</OSName>
1423

0 commit comments

Comments
 (0)