diff --git a/Directory.Build.props b/Directory.Build.props index 0ba2a79969bf1b..e238fe3f9bce95 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -177,89 +177,86 @@ true - - + false true + - <_hostRid Condition="'$(MSBuildRuntimeType)' == 'core'">$([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier) - <_hostRid Condition="'$(MSBuildRuntimeType)' != 'core'">win-$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLowerInvariant) + + + - <_parseDistroRid>$(__DistroRid) - <_parseDistroRid Condition="'$(_parseDistroRid)' == ''">$(_hostRid) - <_distroRidIndex>$(_parseDistroRid.LastIndexOf('-')) + <_portableOS>$(TargetOS.ToLowerInvariant()) + <_portableOS Condition="'$(_portableOS)' == 'windows'">win - <_runtimeOS>$(RuntimeOS) - <_runtimeOS Condition="'$(_runtimeOS)' == ''">$(_parseDistroRid.SubString(0, $(_distroRidIndex))) - - - <_runtimeOS Condition="'$(TargetsMobile)' == 'true'">$(TargetOS.ToLowerInvariant()) - - <_portableOS>linux - <_portableOS Condition="'$(_runtimeOS)' == 'linux-musl' or $(_runtimeOS.StartsWith('alpine'))">linux-musl - <_portableOS Condition="'$(_runtimeOS)' == 'linux-bionic'">linux-bionic - <_portableOS Condition="'$(_hostOS)' == 'osx'">osx - <_portableOS Condition="'$(_runtimeOS)' == 'win' or '$(TargetOS)' == 'windows'">win - <_portableOS Condition="'$(_runtimeOS)' == 'freebsd' or '$(TargetOS)' == 'freebsd'">freebsd - <_portableOS Condition="'$(_runtimeOS)' == 'illumos' or '$(TargetOS)' == 'illumos'">illumos - <_portableOS Condition="'$(_runtimeOS)' == 'solaris' or '$(TargetOS)' == 'solaris'">solaris - <_portableOS Condition="'$(_runtimeOS)' == 'browser'">browser - <_portableOS Condition="'$(_runtimeOS)' == 'wasi'">wasi - <_portableOS Condition="'$(_runtimeOS)' == 'maccatalyst'">maccatalyst - <_portableOS Condition="'$(_runtimeOS)' == 'ios'">ios - <_portableOS Condition="'$(_runtimeOS)' == 'iossimulator'">iossimulator - <_portableOS Condition="'$(_runtimeOS)' == 'tvos'">tvos - <_portableOS Condition="'$(_runtimeOS)' == 'tvossimulator'">tvossimulator - <_portableOS Condition="'$(_runtimeOS)' == 'android'">android - - <_runtimeOS Condition="$(_runtimeOS.StartsWith('tizen'))">linux - <_runtimeOS Condition="'$(PortableBuild)' == 'true'">$(_portableOS) - <_runtimeOS Condition="'$(RuntimeOS)' == '' and '$(DotNetBuildFromSource)' == 'true'">$(_portableOS) - - <_packageLibc Condition="$(_runtimeOS.Contains('musl'))">-musl - <_packageOS Condition="'$(CrossBuild)' == 'true'">$(_hostOS)$(_packageLibc) - <_packageOS Condition="'$(_packageOS)' == '' and '$(PortableBuild)' == 'true'">$(_portableOS) - <_packageOS Condition="'$(_packageOS)' == ''">$(_runtimeOS) + + <_portableOS Condition="'$(_portableOS)' == 'anyos'">$(__PortableTargetOS) + + + <_portableOS Condition="'$(_portableOS)' == 'linux' and '$(__PortableTargetOS)' == 'linux-musl'">linux-musl + <_portableOS Condition="'$(_portableOS)' == 'linux' and '$(__PortableTargetOS)' == 'linux-bionic'">linux-bionic + + + + + <_packageOS>$(_portableOS) + + <_packageOS Condition="'$(CrossBuild)' == 'true' and '$(_portableOS)' != 'linux-musl' and '$(_portableOS)' != 'linux-bionic'">$(_hostOS) + + + $(PackageOS)-$(TargetArchitecture) + $(_packageOS)-$(TargetArchitecture) - - <_toolsRID Condition="'$(CrossBuild)' == 'true'">$(_hostOS)-$(_hostArch) - <_toolsRID Condition="'$(BuildingInsideVisualStudio)' == 'true'">$(_runtimeOS)-x64 - <_toolsRID Condition="'$(_toolsRID)' == ''">$(_runtimeOS)-$(_hostArch) + + + - <_toolsRID Condition="'$(_runtimeOS)' == 'browser' or '$(_runtimeOS)' == 'wasi'">linux-x64 - <_toolsRID Condition="('$(_runtimeOS)' == 'browser' or '$(_runtimeOS)' == 'wasi') and '$(HostOS)' == 'windows'">win-x64 - <_toolsRID Condition="('$(_runtimeOS)' == 'browser' or '$(_runtimeOS)' == 'wasi') and '$(HostOS)' == 'osx'">osx-x64 + To determine _portableHostOS we use _hostOS, similar to how _portableOS is calculated from TargetOS. - - <_toolsRID Condition="'$(_runtimeOS)' == 'android' or '$(_runtimeOS)' == 'linux-bionic'">linux-x64 - <_toolsRID Condition="('$(_runtimeOS)' == 'android' or '$(_runtimeOS)' == 'linux-bionic') and '$(HostOS)' == 'windows'">win-x64 - <_toolsRID Condition="('$(_runtimeOS)' == 'android' or '$(_runtimeOS)' == 'linux-bionic') and '$(HostOS)' == 'osx'">osx-x64 + When we're not cross-building we can detect linux flavors by looking at _portableOS + because the target platform and the build host platform are the same. + For cross-builds, we're currently unable to detect the flavors. --> + <_portableHostOS>$(_hostOS) + <_portableHostOS Condition="'$(_portableHostOS)' == 'windows'">win + <_portableHostOS Condition="'$(CrossBuild)' != 'true' and '$(_portableOS)' == 'linux-musl'">linux-musl - - <_toolsRID Condition="'$(_runtimeOS)' == 'maccatalyst' or '$(_runtimeOS)' == 'ios' or '$(_runtimeOS)' == 'iossimulator' or '$(_runtimeOS)' == 'tvos' or '$(_runtimeOS)' == 'tvossimulator'">osx-x64 + + $(ToolsOS)-$(_hostArch) + $(_portableHostOS)-$(_hostArch) - - linux-$(_hostArch) - $(_toolsRID) + $(ToolsRID) + - $(_packageOS)-$(TargetArchitecture) + + - $(_hostRid) - $(PackageRID) - $(_portableOS)-$(TargetArchitecture) - true - true + <_hostRid Condition="'$(MSBuildRuntimeType)' == 'core'">$([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier) + <_hostRid Condition="'$(MSBuildRuntimeType)' != 'core'">win-$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLowerInvariant) + + <_parseDistroRid>$(__DistroRid) + <_parseDistroRid Condition="'$(_parseDistroRid)' == ''">$(_hostRid) + <_distroRidIndex>$(_parseDistroRid.LastIndexOf('-')) + + <_outputOS>$(_parseDistroRid.SubString(0, $(_distroRidIndex))) + <_outputOS Condition="'$(PortableBuild)' == 'true'">$(_portableOS) + + $(_outputOS)-$(TargetArchitecture) - + true true true true + true + true true true true @@ -279,14 +276,14 @@ $([MSBuild]::NormalizeDirectory('$(MicrosoftNetCoreAppRefPackDir)', 'ref', '$(NetCoreAppCurrent)')) $([MSBuild]::NormalizeDirectory('$(MicrosoftNetCoreAppRefPackDir)', 'data')) - $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'microsoft.netcore.app.runtime.$(OutputRid)', '$(LibrariesConfiguration)')) - $([MSBuild]::NormalizeDirectory('$(MicrosoftNetCoreAppRuntimePackDir)', 'runtimes', '$(OutputRid)')) + $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'microsoft.netcore.app.runtime.$(OutputRID)', '$(LibrariesConfiguration)')) + $([MSBuild]::NormalizeDirectory('$(MicrosoftNetCoreAppRuntimePackDir)', 'runtimes', '$(OutputRID)')) $([MSBuild]::NormalizeDirectory('$(MicrosoftNetCoreAppRuntimePackRidDir)', 'lib', '$(NetCoreAppCurrent)')) $([MSBuild]::NormalizeDirectory('$(MicrosoftNetCoreAppRuntimePackRidDir)', 'native')) - $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', '$(OutputRid).$(HostConfiguration)', 'corehost')) + $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', '$(OutputRID).$(HostConfiguration)', 'corehost')) diff --git a/docs/coding-guidelines/project-guidelines.md b/docs/coding-guidelines/project-guidelines.md index 8bb511be52f906..0d76e3276cd62b 100644 --- a/docs/coding-guidelines/project-guidelines.md +++ b/docs/coding-guidelines/project-guidelines.md @@ -29,7 +29,6 @@ The following are the properties associated with each build pivot - `$(TargetOS) -> windows | linux | osx | freebsd | ... | [defaults to running OS when empty]` - `$(Configuration) -> Debug | Release | [defaults to Debug when empty]` - `$(TargetArchitecture) - x86 | x64 | arm | arm64 | [defaults to x64 when empty]` -- `$(RuntimeOS) - win7 | osx10.10 | ubuntu.14.04 | [any other RID OS+version] | [defaults to running OS when empty]` See [RIDs](https://github.com/dotnet/runtime/tree/main/src/libraries/Microsoft.NETCore.Platforms) for more info. ## Aggregate build properties Each project will define a set of supported TargetFrameworks @@ -63,8 +62,6 @@ A full or individual project build is centered around BuildTargetFramework, Targ 2. If nothing is passed to the build then we will default value of these properties from the environment. Example: `net8.0-[TargetOS Running On]-Debug-x64`. 3. When building an individual project (either from the CLI or an IDE), all target frameworks are built. -We also have `RuntimeOS` which can be passed to customize the specific OS and version needed for native package builds as well as package restoration. If not passed it will default based on the OS you are running on. - Any of the mentioned properties can be set via `/p:=` at the command line. When building using any of the wrapper scripts around it (i.e. build.cmd) a number of these properties have aliases which make them easier to pass (run build.cmd/sh -? for the aliases). ## Selecting the correct BuildSettings diff --git a/eng/SourceBuild.props b/eng/SourceBuild.props index 5a8e7a4b4f05d4..bbf4b6996cea33 100644 --- a/eng/SourceBuild.props +++ b/eng/SourceBuild.props @@ -31,10 +31,11 @@ $(InnerBuildArgs) --nodereuse false $(InnerBuildArgs) --warnAsError false $(InnerBuildArgs) --outputrid $(TargetRid) - - $(InnerBuildArgs) /p:RuntimeOS=$(RuntimeOS) + + $(InnerBuildArgs) /p:PackageOS=$(RuntimeOS) /p:ToolsOS=$(RuntimeOS) + It's used to add TargetRid in the graph if the parent can't be detected. --> $(InnerBuildArgs) /p:AdditionalRuntimeIdentifierParent=$(BaseOS) $(InnerBuildArgs) /p:OfficialBuildId=$(OfficialBuildId) $(InnerBuildArgs) /p:ContinuousIntegrationBuild=$(ContinuousIntegrationBuild) diff --git a/eng/build.ps1 b/eng/build.ps1 index 6bf2dc78f7c067..99f0864317f39a 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -304,13 +304,6 @@ foreach ($config in $configuration) { $argumentsWithConfig = $arguments + " -configuration $((Get-Culture).TextInfo.ToTitleCase($config))"; foreach ($singleArch in $arch) { $argumentsWithArch = "/p:TargetArchitecture=$singleArch " + $argumentsWithConfig - if ($os -eq "browser") { - $env:__DistroRid="browser-$singleArch" - } elseif ($os -eq "wasi") { - $env:__DistroRid="wasi-$singleArch" - } else { - $env:__DistroRid="win-$singleArch" - } Invoke-Expression "& `"$PSScriptRoot/common/build.ps1`" $argumentsWithArch" if ($lastExitCode -ne 0) { $failedBuilds += "Configuration: $config, Architecture: $singleArch" diff --git a/eng/build.sh b/eng/build.sh index 1147ec248a7842..14855d30b0f1c6 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -31,7 +31,8 @@ usage() echo " --librariesConfiguration (-lc) Libraries build configuration: Debug or Release." echo " [Default: Debug]" echo " --os Target operating system: windows, linux, freebsd, osx, maccatalyst, tvos," - echo " tvossimulator, ios, iossimulator, android, browser, wasi, netbsd, illumos or solaris." + echo " tvossimulator, ios, iossimulator, android, browser, wasi, netbsd, illumos, solaris" + echo " linux-musl or linux-bionic." echo " [Default: Your machine's OS.]" echo " --outputrid Optional argument that overrides the target rid name." echo " --projects Project or solution file(s) to build." @@ -134,7 +135,7 @@ initDistroRid() local passedRootfsDir="" local targetOs="$1" - local buildArch="$2" + local targetArch="$2" local isCrossBuild="$3" local isPortableBuild="$4" @@ -142,7 +143,7 @@ initDistroRid() if [[ $isCrossBuild == 1 && "$targetOs" != "osx" ]]; then passedRootfsDir=${ROOTFS_DIR} fi - initDistroRidGlobal ${targetOs} ${buildArch} ${isPortableBuild} ${passedRootfsDir} + initDistroRidGlobal "${targetOs}" "${targetArch}" "${isPortableBuild}" "${passedRootfsDir}" } showSubsetHelp() @@ -286,6 +287,14 @@ while [[ $# > 0 ]]; do os="illumos" ;; solaris) os="solaris" ;; + linux-bionic) + os="linux" + __PortableTargetOS=linux-bionic + ;; + linux-musl) + os="linux" + __PortableTargetOS=linux-musl + ;; *) echo "Unsupported target OS '$2'." echo "The allowed values are windows, linux, freebsd, osx, maccatalyst, tvos, tvossimulator, ios, iossimulator, android, browser, wasi, illumos and solaris." @@ -438,7 +447,7 @@ while [[ $# > 0 ]]; do echo "No value for outputrid is supplied. See help (--help) for supported values." 1>&2 exit 1 fi - arguments="$arguments /p:OutputRid=$(echo "$2" | tr "[:upper:]" "[:lower:]")" + arguments="$arguments /p:OutputRID=$(echo "$2" | tr "[:upper:]" "[:lower:]")" shift 2 ;; @@ -516,7 +525,7 @@ if [[ "${TreatWarningsAsErrors:-}" == "false" ]]; then arguments="$arguments -warnAsError 0" fi -initDistroRid $os $arch $crossBuild $portableBuild +initDistroRid "$os" "$arch" "$crossBuild" "$portableBuild" # Disable targeting pack caching as we reference a partially constructed targeting pack and update it later. # The later changes are ignored when using the cache. diff --git a/eng/common/templates/steps/source-build.yml b/eng/common/templates/steps/source-build.yml index a97a185a367a92..4ec5577d28a0c6 100644 --- a/eng/common/templates/steps/source-build.yml +++ b/eng/common/templates/steps/source-build.yml @@ -63,11 +63,6 @@ steps: targetRidArgs='/p:TargetRid=${{ parameters.platform.targetRID }}' fi - runtimeOsArgs= - if [ '${{ parameters.platform.runtimeOS }}' != '' ]; then - runtimeOsArgs='/p:RuntimeOS=${{ parameters.platform.runtimeOS }}' - fi - publishArgs= if [ '${{ parameters.platform.skipPublishValidation }}' != 'true' ]; then publishArgs='--publish' @@ -85,7 +80,6 @@ steps: $internalRuntimeDownloadArgs \ $internalRestoreArgs \ $targetRidArgs \ - $runtimeOsArgs \ /p:SourceBuildNonPortable=${{ parameters.platform.nonPortable }} \ /p:ArcadeBuildFromSource=true \ /p:AssetManifestFileName=$assetManifestFileName diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index 905cc125f9286b..509063d7a4a43f 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -284,7 +284,6 @@ source "$__RepoRootDir/eng/native/init-os-and-arch.sh" __TargetArch=$arch __TargetOS=$os __HostOS=$os -__BuildOS=$os __OutputRid='' # Get the number of processors available to the scheduler @@ -537,12 +536,17 @@ if [[ "$__CrossBuild" == 1 ]]; then fi fi -# init the target distro name +# init the target distro name (__DistroRid) and target portable os (__PortableTargetOS). initTargetDistroRid - if [ -z "$__OutputRid" ]; then - __OutputRid="$(echo $__DistroRid | tr '[:upper:]' '[:lower:]')" + if [[ "$__PortableBuild" == 0 ]]; then + __OutputRid="$__DistroRid" + else + __OutputRid="$__PortableTargetOS-$__TargetArch" + fi fi +export __OutputRid +echo "__OutputRid: ${__OutputRid}" # When the host runs on an unknown rid, it falls back to the output rid __HostFallbackOS="${__OutputRid%-*}" # Strip architecture diff --git a/eng/native/init-distro-rid.sh b/eng/native/init-distro-rid.sh index 3f22de10061fa3..da1a1e39a0ba3e 100644 --- a/eng/native/init-distro-rid.sh +++ b/eng/native/init-distro-rid.sh @@ -1,105 +1,74 @@ #!/usr/bin/env bash -# initNonPortableDistroRid +# getNonPortableDistroRid # # Input: # targetOs: (str) -# buildArch: (str) -# isPortable: (int) +# targetArch: (str) # rootfsDir: (str) # # Return: -# None -# -# Notes: -# -# initNonPortableDistroRid will attempt to initialize a non portable rid. These -# rids are specific to distros need to build the product/package and consume -# them on the same platform. -# -# If -portablebuild=false is passed a non-portable rid will be created for any -# distro. -# -# It is important to note that the function does not return anything, but it -# exports __DistroRid, if there is a non-portable distro rid to be used. -# -initNonPortableDistroRid() +# non-portable rid +getNonPortableDistroRid() { - # Make sure out parameter is cleared. - __DistroRid= - local targetOs="$1" - local buildArch="$2" - local isPortable="$3" - local rootfsDir="$4" - local nonPortableBuildID="" + local targetArch="$2" + local rootfsDir="$3" + local nonPortableRid="" if [ "$targetOs" = "linux" ]; then if [ -e "${rootfsDir}/etc/os-release" ]; then source "${rootfsDir}/etc/os-release" - # We have forced __PortableBuild=0. This is because -portablebuld - # has been passed as false. - if (( isPortable == 0 )); then - if [[ "${ID}" == "rhel" || "${ID}" == "rocky" || "${ID}" == "alpine" ]]; then - # remove the last version digit - VERSION_ID="${VERSION_ID%.*}" - fi + if [[ "${ID}" == "rhel" || "${ID}" == "rocky" || "${ID}" == "alpine" ]]; then + # remove the last version digit + VERSION_ID="${VERSION_ID%.*}" + fi - if [[ "${VERSION_ID}" =~ ^([[:digit:]]|\.)+$ ]]; then - nonPortableBuildID="${ID}.${VERSION_ID}-${buildArch}" - else - # Rolling release distros either do not set VERSION_ID, set it as blank or - # set it to non-version looking string (such as TEMPLATE_VERSION_ID on ArchLinux); - # so omit it here to be consistent with everything else. - nonPortableBuildID="${ID}-${buildArch}" - fi + if [[ "${VERSION_ID}" =~ ^([[:digit:]]|\.)+$ ]]; then + nonPortableRid="${ID}.${VERSION_ID}-${targetArch}" + else + # Rolling release distros either do not set VERSION_ID, set it as blank or + # set it to non-version looking string (such as TEMPLATE_VERSION_ID on ArchLinux); + # so omit it here to be consistent with everything else. + nonPortableRid="${ID}-${targetArch}" fi elif [ -e "${rootfsDir}/android_platform" ]; then source "$rootfsDir"/android_platform - nonPortableBuildID="$RID" + nonPortableRid="$RID" fi fi if [ "$targetOs" = "freebsd" ]; then - if (( isPortable == 0 )); then - # $rootfsDir can be empty. freebsd-version is shell script and it should always work. - __freebsd_major_version=$($rootfsDir/bin/freebsd-version | { read v; echo "${v%%.*}"; }) - nonPortableBuildID="freebsd.$__freebsd_major_version-${buildArch}" - fi + # $rootfsDir can be empty. freebsd-version is shell script and it should always work. + __freebsd_major_version=$($rootfsDir/bin/freebsd-version | { read v; echo "${v%%.*}"; }) + nonPortableRid="freebsd.$__freebsd_major_version-${targetArch}" elif command -v getprop && getprop ro.product.system.model 2>&1 | grep -qi android; then __android_sdk_version=$(getprop ro.build.version.sdk) - nonPortableBuildID="android.$__android_sdk_version-${buildArch}" + nonPortableRid="android.$__android_sdk_version-${targetArch}" elif [ "$targetOs" = "illumos" ]; then __uname_version=$(uname -v) case "$__uname_version" in omnios-*) __omnios_major_version=$(echo "${__uname_version:8:2}") - nonPortableBuildID=omnios."$__omnios_major_version"-"$buildArch" + nonPortableRid=omnios."$__omnios_major_version"-"$targetArch" ;; joyent_*) __smartos_major_version=$(echo "${__uname_version:7:4}") - nonPortableBuildID=smartos."$__smartos_major_version"-"$buildArch" + nonPortableRid=smartos."$__smartos_major_version"-"$targetArch" ;; illumos_*) - nonPortableBuildID=openindiana-"$buildArch" + nonPortableRid=openindiana-"$targetArch" ;; esac elif [ "$targetOs" = "solaris" ]; then __uname_version=$(uname -v) __solaris_major_version=$(echo "${__uname_version%.*}") - nonPortableBuildID=solaris."$__solaris_major_version"-"$buildArch" + nonPortableRid=solaris."$__solaris_major_version"-"$targetArch" fi - if [ -n "${nonPortableBuildID}" ]; then - __DistroRid="${nonPortableBuildID}" - - # We are using a non-portable build rid. Force __PortableBuild to false. - __PortableBuild=0 - - export __DistroRid __PortableBuild - fi + echo "$(echo $nonPortableRid | tr '[:upper:]' '[:lower:]')" } # initDistroRidGlobal @@ -118,20 +87,13 @@ initNonPortableDistroRid() # It is important to note that the function does not return anything, but it # exports the following variables on success: # -# __DistroRid -# __PortableBuild +# __DistroRid : Non-portable rid of the target platform. +# __PortableTargetOS : OS-part of the portable rid that corresponds to the target platform. # initDistroRidGlobal() { - # __DistroRid must be set at the end of the function. - # Previously we would create a variable __HostDistroRid and/or __DistroRid. - # - # __HostDistroRid was used in the case of a non-portable build, it has been - # deprecated. Now only __DistroRid is supported. It will be used for both - # portable and non-portable rids and will be used in build-packages.sh - local targetOs="$1" - local buildArch="$2" + local targetArch="$2" local isPortable="$3" local rootfsDir="" if [ "$#" -ge 4 ]; then @@ -146,71 +108,17 @@ initDistroRidGlobal() fi fi - initNonPortableDistroRid "${targetOs}" "${buildArch}" "${isPortable}" "${rootfsDir}" - - if [ "$buildArch" = "wasm" ]; then - if [ "$targetOs" = "browser" ]; then - __DistroRid=browser-wasm - export __DistroRid - elif [ "$targetOs" = "wasi" ]; then - __DistroRid=wasi-wasm - export __DistroRid - fi - fi - - if [ -z "${__DistroRid}" ]; then - # The non-portable build rid was not set. Set the portable rid. + __DistroRid=$(getNonPortableDistroRid "${targetOs}" "${targetArch}" "${rootfsDir}") - __PortableBuild=1 - export __PortableBuild - local distroRid="" + if [ -z "${__PortableTargetOS:-}" ]; then + __PortableTargetOS="$targetOs" # Check for musl-based distros (e.g Alpine Linux, Void Linux). if "${rootfsDir}/usr/bin/ldd" --version 2>&1 | grep -q musl || strings "${rootfsDir}/usr/bin/ldd" 2>&1 | grep -q musl; then - distroRid="linux-musl-${buildArch}" + __PortableTargetOS="linux-musl" fi - - if [ -z "${distroRid}" ]; then - if [ "$targetOs" = "linux" ]; then - distroRid="linux-$buildArch" - elif [ "$targetOs" = "linux-bionic" ]; then - distroRid="linux-bionic-$buildArch" - elif [ "$targetOs" = "osx" ]; then - distroRid="osx-$buildArch" - elif [ "$targetOs" = "maccatalyst" ]; then - distroRid="maccatalyst-$buildArch" - elif [ "$targetOs" = "tvos" ]; then - distroRid="tvos-$buildArch" - elif [ "$targetOs" = "tvossimulator" ]; then - distroRid="tvossimulator-$buildArch" - elif [ "$targetOs" = "ios" ]; then - distroRid="ios-$buildArch" - elif [ "$targetOs" = "iossimulator" ]; then - distroRid="iossimulator-$buildArch" - elif [ "$targetOs" = "android" ]; then - distroRid="android-$buildArch" - elif [ "$targetOs" = "browser" ]; then - distroRid="browser-$buildArch" - elif [ "$targetOs" = "wasi" ]; then - distroRid="wasi-$buildArch" - elif [ "$targetOs" = "freebsd" ]; then - distroRid="freebsd-$buildArch" - elif [ "$targetOs" = "illumos" ]; then - distroRid="illumos-$buildArch" - elif [ "$targetOs" = "solaris" ]; then - distroRid="solaris-$buildArch" - fi - fi - - __DistroRid="${distroRid}" - export __DistroRid - fi - - if [ -z "$__DistroRid" ]; then - echo "DistroRid is not set. This is almost certainly an error" - exit 1 fi - echo "__DistroRid: ${__DistroRid}" + export __DistroRid __PortableTargetOS } diff --git a/eng/pipelines/common/global-build-job.yml b/eng/pipelines/common/global-build-job.yml index 6124c13390ee6f..12f72b0d9e265f 100644 --- a/eng/pipelines/common/global-build-job.yml +++ b/eng/pipelines/common/global-build-job.yml @@ -73,7 +73,7 @@ jobs: - ${{ if and(eq(parameters.osGroup, 'linux'), eq(parameters.osSubGroup, '_bionic')) }}: - name: _osParameter - value: /p:RuntimeOS=linux-bionic + value: -os linux-bionic - name: crossArg value: '' diff --git a/eng/pipelines/mono/templates/build-job.yml b/eng/pipelines/mono/templates/build-job.yml index cdcf76143f5fdc..3b8176228d197e 100644 --- a/eng/pipelines/mono/templates/build-job.yml +++ b/eng/pipelines/mono/templates/build-job.yml @@ -70,7 +70,7 @@ jobs: # Set output RID manually: musl isn't properly detected. Make sure to also convert linux to # lowercase for RID format. (Detection normally converts, but we're preventing it.) - name: OutputRidArg - value: /p:OutputRid=linux-musl-${{ parameters.archType }} + value: /p:OutputRID=linux-musl-${{ parameters.archType }} - name: _PortableBuild value: true - ${{ if eq(parameters.osGroup, 'tvos') }}: diff --git a/eng/testing/tests.props b/eng/testing/tests.props index ab58a76a58c3b5..2c555d1abaffe0 100644 --- a/eng/testing/tests.props +++ b/eng/testing/tests.props @@ -17,7 +17,7 @@ $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AndroidTestRunner', '$(Configuration)', '$(NetCoreAppCurrent)')) $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'WasmTestRunner', '$(Configuration)', '$(NetCoreAppCurrent)')) - $(OutputRid) + $(OutputRID) true diff --git a/eng/testing/tests.singlefile.targets b/eng/testing/tests.singlefile.targets index 6b869bd02c60a3..5fb0e1bd643ea2 100644 --- a/eng/testing/tests.singlefile.targets +++ b/eng/testing/tests.singlefile.targets @@ -4,7 +4,7 @@ $([MSBuild]::NormalizeDirectory('$(OutDir)', 'publish')) $([MSBuild]::NormalizePath('$(BundleDir)', '$(RunScriptOutputName)')) - $(OutputRid) + $(OutputRID) $(AssemblyName).exe chmod +rwx $(AssemblyName) && ./$(AssemblyName) diff --git a/src/coreclr/.nuget/Directory.Build.props b/src/coreclr/.nuget/Directory.Build.props index cb446cf9c41e72..150e9ccfb0b82b 100644 --- a/src/coreclr/.nuget/Directory.Build.props +++ b/src/coreclr/.nuget/Directory.Build.props @@ -120,8 +120,8 @@ - - + amd64 $(TargetArchitecture) diff --git a/src/coreclr/.nuget/builds.targets b/src/coreclr/.nuget/builds.targets index 4dd4d825baeb96..e9acb038c46073 100644 --- a/src/coreclr/.nuget/builds.targets +++ b/src/coreclr/.nuget/builds.targets @@ -7,11 +7,11 @@ - + - <_projectsToBuild Include="@(Project)" Condition="'%(Project.PackageTargetRuntime)' == '$(OutputRid)'" /> + <_projectsToBuild Include="@(Project)" Condition="'%(Project.PackageTargetRuntime)' == '$(OutputRID)'" /> diff --git a/src/coreclr/build-runtime.sh b/src/coreclr/build-runtime.sh index 2b99c9b9eed5f0..49d2627630a426 100755 --- a/src/coreclr/build-runtime.sh +++ b/src/coreclr/build-runtime.sh @@ -81,7 +81,6 @@ __Compiler=clang __CommonMSBuildArgs= __ConfigureOnly=0 __CrossBuild=0 -__DistroRid="" __PgoInstrument=0 __PgoOptDataPath="" __PgoOptimize=0 diff --git a/src/coreclr/runtime.proj b/src/coreclr/runtime.proj index d7744c34333369..7f8edcc93a7813 100644 --- a/src/coreclr/runtime.proj +++ b/src/coreclr/runtime.proj @@ -37,7 +37,7 @@ <_CoreClrBuildArg Condition="'$(PgoInstrument)' == 'true'" Include="-pgoinstrument" /> <_CoreClrBuildArg Condition="'$(NativeOptimizationDataSupported)' == 'true' and '$(NoPgoOptimize)' != 'true' and '$(PgoInstrument)' != 'true'" Include="-pgodatapath "$(PgoPackagePath)"" /> <_CoreClrBuildArg Condition="'$(HostArchitecture)' != ''" Include="-hostarch $(HostArchitecture)" /> - <_CoreClrBuildArg Include="-outputrid $(OutputRid)" /> + <_CoreClrBuildArg Include="-outputrid $(OutputRID)" /> diff --git a/src/coreclr/tools/SuperFileCheck/SuperFileCheck.csproj b/src/coreclr/tools/SuperFileCheck/SuperFileCheck.csproj index 793d6690074e43..7c76b9fa817b42 100644 --- a/src/coreclr/tools/SuperFileCheck/SuperFileCheck.csproj +++ b/src/coreclr/tools/SuperFileCheck/SuperFileCheck.csproj @@ -15,10 +15,10 @@ - - <_jitToolsRidPlatformIndex>$(OutputRid.LastIndexOf('-')) - $(OutputRid.Substring(0, $(_jitToolsRidPlatformIndex))) - $(OutputRid.Substring($(_jitToolsRidPlatformIndex)).TrimStart('-')) + + <_jitToolsRidPlatformIndex>$(OutputRID.LastIndexOf('-')) + $(OutputRID.Substring(0, $(_jitToolsRidPlatformIndex))) + $(OutputRID.Substring($(_jitToolsRidPlatformIndex)).TrimStart('-')) linux diff --git a/src/installer/Directory.Build.props b/src/installer/Directory.Build.props index 44582bc378b271..33a094c082f790 100644 --- a/src/installer/Directory.Build.props +++ b/src/installer/Directory.Build.props @@ -8,8 +8,8 @@ $(TargetArchitecture) $(DefineConstants),DEBUG,TRACE $(DefineConstants),TRACE - $(OutputRid) - $(OutputRid) + $(OutputRID) + $(OutputRID) diff --git a/src/installer/pkg/projects/Directory.Build.props b/src/installer/pkg/projects/Directory.Build.props index e95f6a113e7874..5f04dc00030530 100644 --- a/src/installer/pkg/projects/Directory.Build.props +++ b/src/installer/pkg/projects/Directory.Build.props @@ -122,7 +122,7 @@ @(RestoreBuildRID) - $(OutputRid) + $(OutputRID) diff --git a/src/installer/pkg/projects/host-packages.proj b/src/installer/pkg/projects/host-packages.proj index 9a6e896b59f87f..772ee1b0f6369f 100644 --- a/src/installer/pkg/projects/host-packages.proj +++ b/src/installer/pkg/projects/host-packages.proj @@ -4,6 +4,6 @@ - + diff --git a/src/installer/pkg/projects/nativeaot-packages.proj b/src/installer/pkg/projects/nativeaot-packages.proj index 10ab1d60c56fa5..592b4565154216 100644 --- a/src/installer/pkg/projects/nativeaot-packages.proj +++ b/src/installer/pkg/projects/nativeaot-packages.proj @@ -4,7 +4,7 @@ - + diff --git a/src/installer/tests/Directory.Build.targets b/src/installer/tests/Directory.Build.targets index 7691ad32cee765..43154f340b7807 100644 --- a/src/installer/tests/Directory.Build.targets +++ b/src/installer/tests/Directory.Build.targets @@ -73,7 +73,7 @@ - + diff --git a/src/libraries/Directory.Build.props b/src/libraries/Directory.Build.props index f5c03d347e4055..3f808e7eb4f6a1 100644 --- a/src/libraries/Directory.Build.props +++ b/src/libraries/Directory.Build.props @@ -1,6 +1,5 @@ - true true + They are filtered in the traversal build in oob-all.csproj based on the OutputRID. --> diff --git a/src/libraries/System.IO.Ports/pkg/runtime.native.System.IO.Ports.props b/src/libraries/System.IO.Ports/pkg/runtime.native.System.IO.Ports.props index bda41ce5319625..8ee8a9c20d8d7b 100644 --- a/src/libraries/System.IO.Ports/pkg/runtime.native.System.IO.Ports.props +++ b/src/libraries/System.IO.Ports/pkg/runtime.native.System.IO.Ports.props @@ -15,14 +15,14 @@ diff --git a/src/libraries/System.Net.Http/tests/StressTests/HttpStress/Directory.Build.props b/src/libraries/System.Net.Http/tests/StressTests/HttpStress/Directory.Build.props index 9ca35839f9c1be..509bca64fdc3d0 100644 --- a/src/libraries/System.Net.Http/tests/StressTests/HttpStress/Directory.Build.props +++ b/src/libraries/System.Net.Http/tests/StressTests/HttpStress/Directory.Build.props @@ -1,7 +1,7 @@ - linux-x64 - win-x64 + linux-x64 + win-x64 $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)../, global.json))/ @@ -12,6 +12,6 @@ 8.0 Microsoft.NETCore.App $(RepositoryRoot)artifacts/bin/microsoft.netcore.app.ref/ - $(RepositoryRoot)artifacts/bin/microsoft.netcore.app.runtime.$(OutputRid)/$(Configuration)/ + $(RepositoryRoot)artifacts/bin/microsoft.netcore.app.runtime.$(OutputRID)/$(Configuration)/ \ No newline at end of file diff --git a/src/libraries/System.Net.Security/tests/StressTests/SslStress/Directory.Build.props b/src/libraries/System.Net.Security/tests/StressTests/SslStress/Directory.Build.props index 70928e5355ab11..0183d8b3696f4e 100644 --- a/src/libraries/System.Net.Security/tests/StressTests/SslStress/Directory.Build.props +++ b/src/libraries/System.Net.Security/tests/StressTests/SslStress/Directory.Build.props @@ -1,7 +1,7 @@ - linux-x64 - win-x64 + linux-x64 + win-x64 $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)../, global.json))/ @@ -12,6 +12,6 @@ 8.0 Microsoft.NETCore.App $(RepositoryRoot)artifacts/bin/microsoft.netcore.app.ref/ - $(RepositoryRoot)artifacts/bin/microsoft.netcore.app.runtime.$(OutputRid)/$(Configuration)/ + $(RepositoryRoot)artifacts/bin/microsoft.netcore.app.runtime.$(OutputRID)/$(Configuration)/ \ No newline at end of file diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj index 592a6f0fe24f08..4ba1f17dd095ef 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj @@ -11,7 +11,7 @@ to the apphost to make sure that it is built before this project invokes DNNE. --> false - $(OutputRid) + $(OutputRID) $(PackageRID) <_TargetsAppleOS Condition="'$(TargetOS)' == 'osx' or '$(TargetOS)' == 'maccatalyst' or '$(TargetOS)' == 'ios' or '$(TargetOS)' == 'tvos' or '$(TargetOS)' == 'iossimulator' or diff --git a/src/libraries/oob-src.proj b/src/libraries/oob-src.proj index 5eb6a2f74e41b9..498a88d5a563fe 100644 --- a/src/libraries/oob-src.proj +++ b/src/libraries/oob-src.proj @@ -15,9 +15,9 @@ @(NetCoreAppLibrary->'%(Identity)\src\%(Identity).csproj'); Microsoft.VisualBasic.Core\src\Microsoft.VisualBasic.Core.vbproj" /> - - diff --git a/src/libraries/oob.proj b/src/libraries/oob.proj index 074f952826da4a..8eec5f78284906 100644 --- a/src/libraries/oob.proj +++ b/src/libraries/oob.proj @@ -56,7 +56,7 @@ DependsOnTargets="GetTrimOOBAssembliesInputs;PrepareForAssembliesTrim" Inputs="$(ILLinkTasksAssembly);@(OOBAssemblyToTrim);@(OOBAssemblyReference);@(OOBLibrarySuppressionsXml)" Outputs="$(OOBAssembliesTrimMarkerFile)"> - + $(ILLinkArgs) diff --git a/src/libraries/pretest.proj b/src/libraries/pretest.proj index 6118eb1120e6a2..3bee7105912e7f 100644 --- a/src/libraries/pretest.proj +++ b/src/libraries/pretest.proj @@ -71,10 +71,10 @@ Outputs="$(MicrosoftNetCoreAppRuntimePackDir)data\PlatformManifest.txt" Condition="'$(BuildTargetFramework)' == '$(NetCoreAppCurrent)' or '$(BuildTargetFramework)' == ''"> @@ -103,16 +103,16 @@ + TargetRuntimeIdentifier="$(OutputRID)" /> - runtimes/$(OutputRid)/lib/$(NetCoreAppCurrent) + runtimes/$(OutputRID)/lib/$(NetCoreAppCurrent) - runtimes/$(OutputRid)/native + runtimes/$(OutputRID)/native true diff --git a/src/libraries/sfx.proj b/src/libraries/sfx.proj index d5a37e1959d30e..f23bfea607ea37 100644 --- a/src/libraries/sfx.proj +++ b/src/libraries/sfx.proj @@ -43,7 +43,7 @@ Condition="'$(RefOnly)' != 'true'" Inputs="@(SharedFrameworkAssembly);@(SharedFrameworkSuppressionsXml);$(ILLinkTasksAssembly)" Outputs="$(SharedFrameworkAssembliesTrimMarkerFile)"> - + $(ILLinkArgs) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index f0a7d7e6ab82c1..74c81fea56fdba 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -954,10 +954,10 @@ $(RuntimeBinDir)%(_MonoRuntimeComponentsSharedFilePath.Filename)%(_MonoRuntimeComponentsSharedFilePath.Extension) <_MonoRuntimeArtifacts Include="$(_MonoAotCrossFilePath)"> - $(RuntimeBinDir)cross\$(OutputRid)\$(MonoAotCrossFileName) + $(RuntimeBinDir)cross\$(OutputRID)\$(MonoAotCrossFileName) <_MonoRuntimeArtifacts Include="$(_MonoAotCrossPdbFilePath)" Condition="Exists('$(_MonoAotCrossPdbFilePath)')"> - $(RuntimeBinDir)cross\$(OutputRid)\$(MonoAotCrossPdbFileName) + $(RuntimeBinDir)cross\$(OutputRID)\$(MonoAotCrossPdbFileName) <_MonoRuntimeArtifacts Condition="'$(MonoBundleLLVMOptimizer)' == 'true'" Include="$(MonoLLVMDir)\$(_MonoLLVMTargetArchitecture)\bin\llc$(ExeSuffix)"> $(RuntimeBinDir)\llc$(ExeSuffix) @@ -966,10 +966,10 @@ $(RuntimeBinDir)\opt$(ExeSuffix) <_MonoRuntimeArtifacts Condition="'$(MonoAOTBundleLLVMOptimizer)' == 'true'" Include="$(MonoLLVMDir)\$(_MonoLLVMTargetArchitecture)\bin\llc$(ExeSuffix)"> - $(RuntimeBinDir)cross\$(OutputRid)\llc$(ExeSuffix) + $(RuntimeBinDir)cross\$(OutputRID)\llc$(ExeSuffix) <_MonoRuntimeArtifacts Condition="'$(MonoAOTBundleLLVMOptimizer)' == 'true'" Include="$(MonoLLVMDir)\$(_MonoLLVMTargetArchitecture)\bin\opt$(ExeSuffix)"> - $(RuntimeBinDir)cross\$(OutputRid)\opt$(ExeSuffix) + $(RuntimeBinDir)cross\$(OutputRID)\opt$(ExeSuffix) <_MonoIncludeArtifacts Include="$(MonoObjDir)out\include\**" /> <_MonoRuntimeArtifacts Condition="'$(MonoComponentsStatic)' != 'true' and Exists('$(MonoObjDir)out\lib\Mono.release.framework')" Include="@(_MonoRuntimeComponentsSharedFilePath)"> diff --git a/src/native/corehost/corehost.proj b/src/native/corehost/corehost.proj index d489571ed9ec51..18ac25f41841d2 100644 --- a/src/native/corehost/corehost.proj +++ b/src/native/corehost/corehost.proj @@ -8,7 +8,7 @@ true GetProductVersions;GenerateNativeVersionFile $(BuildCoreHostDependsOn);InitializeSourceControlInformationFromSourceControlManager - $(ArtifactsObjDir)$(OutputRid).$(Configuration)\ + $(ArtifactsObjDir)$(OutputRID).$(Configuration)\ @@ -82,7 +82,7 @@ $(BuildArgs) -ninja $(BuildArgs) -runtimeflavor $(RuntimeFlavor) $(BuildArgs) /p:OfficialBuildId="$(OfficialBuildId)" - $(BuildArgs) -outputrid $(OutputRid) + $(BuildArgs) -outputrid $(OutputRID) - $(OutputRid) + $(OutputRID) diff --git a/src/tests/Common/publishdependency.targets b/src/tests/Common/publishdependency.targets index 30b541ecea7784..4a16052008d7d2 100644 --- a/src/tests/Common/publishdependency.targets +++ b/src/tests/Common/publishdependency.targets @@ -28,7 +28,7 @@ + Properties="Language=C#;RuntimeIdentifier=$(OutputRID);CORE_ROOT=$(CORE_ROOT)" /> diff --git a/src/tests/Common/test_dependencies/test_dependencies.csproj b/src/tests/Common/test_dependencies/test_dependencies.csproj index 38417a9e8e31ae..454e4003f0c20f 100644 --- a/src/tests/Common/test_dependencies/test_dependencies.csproj +++ b/src/tests/Common/test_dependencies/test_dependencies.csproj @@ -5,7 +5,7 @@ $(NetCoreAppToolCurrent) true true - win-arm;win-arm64;win-x64;win-x86;$(OutputRid) + win-arm;win-arm64;win-x64;win-x86;$(OutputRID) true diff --git a/src/tests/Common/test_dependencies_fs/test_dependencies.fsproj b/src/tests/Common/test_dependencies_fs/test_dependencies.fsproj index 196db8eabec630..b7e9dde969981d 100644 --- a/src/tests/Common/test_dependencies_fs/test_dependencies.fsproj +++ b/src/tests/Common/test_dependencies_fs/test_dependencies.fsproj @@ -5,7 +5,7 @@ $(NetCoreAppToolCurrent) true true - win-arm;win-arm64;win-x64;win-x86;$(OutputRid) + win-arm;win-arm64;win-x64;win-x86;$(OutputRID) true diff --git a/src/tests/Directory.Build.targets b/src/tests/Directory.Build.targets index 104f53ebda3a8a..6f6fc552ba222c 100644 --- a/src/tests/Directory.Build.targets +++ b/src/tests/Directory.Build.targets @@ -531,7 +531,7 @@ $(CoreCLRAotSdkDir) $(MicrosoftNetCoreAppRuntimePackRidLibTfmDir) $(MicrosoftNetCoreAppRuntimePackNativeDir) - $(OutputRid) + $(OutputRID) lld $(ROOTFS_DIR) diff --git a/src/tests/build.proj b/src/tests/build.proj index d9df2372171cb0..7f980b6cf4c2fb 100644 --- a/src/tests/build.proj +++ b/src/tests/build.proj @@ -8,7 +8,7 @@ $(XunitTestBinBase)\TestWrappers\ 1 C# - $(OutputRid) + $(OutputRID) @@ -126,8 +126,8 @@ $(MonoBinDir) - $(MonoBinDir)/cross/$(OutputRid)/mono-aot-cross - $(MonoBinDir)/cross/$(OutputRid) + $(MonoBinDir)/cross/$(OutputRID)/mono-aot-cross + $(MonoBinDir)/cross/$(OutputRID) @@ -537,8 +537,7 @@ <_ConfigurationProperties>/p:TargetOS=$(TargetOS) /p:TargetArchitecture=$(TargetArchitecture) /p:Configuration=$(Configuration) /p:CrossBuild=$(CrossBuild) - "$(DotNetTool)" restore $(RestoreProj) $(PackageVersionArg) /p:SetTFMForRestore=true $(_ConfigurationProperties) - "$(DotNetTool)" restore -r $(__DistroRid) $(RestoreProj) $(PackageVersionArg) /p:SetTFMForRestore=true $(_ConfigurationProperties) + "$(DotNetTool)" restore -r $(PackageRID) $(RestoreProj) $(PackageVersionArg) /p:SetTFMForRestore=true $(_ConfigurationProperties) @@ -578,7 +577,8 @@ $(GroupBuildCmd) "/p:Configuration=$(Configuration)" $(GroupBuildCmd) "/p:LibrariesConfiguration=$(LibrariesConfiguration)" $(GroupBuildCmd) "/p:TargetOS=$(TargetOS)" - $(GroupBuildCmd) "/p:RuntimeOS=$(RuntimeOS)" + $(GroupBuildCmd) "/p:ToolsOS=$(ToolsOS)" + $(GroupBuildCmd) "/p:PackageOS=$(PackageOS)" $(GroupBuildCmd) "/p:RuntimeFlavor=$(RuntimeFlavor)" $(GroupBuildCmd) "/p:RuntimeVariant=$(RuntimeVariant)" $(GroupBuildCmd) "/p:CLRTestBuildAllTargets=$(CLRTestBuildAllTargets)" diff --git a/src/tests/build.sh b/src/tests/build.sh index 5d742126a08d02..50efe6a764ebbf 100755 --- a/src/tests/build.sh +++ b/src/tests/build.sh @@ -332,7 +332,6 @@ __ConfigureOnly=0 __CopyNativeProjectsAfterCombinedTestBuild=true __CopyNativeTestBinaries=0 __CrossBuild=0 -__DistroRid="" __CompositeBuildMode= __CreatePerfmap= __TestBuildMode=