msbuild: always use shared library from dotnet-sdk

This changes the use of .so to use the more generic
stdenv.hostPlatform.extensions.sharedLibrary.
This also overrides mono/build/extract_and_copy_hostfxr.sh which uses
the internet and is x86 specific.
This commit is contained in:
MaxHearnden 2023-05-23 20:29:44 +01:00
parent 499cad7a72
commit a3ec8a5128
2 changed files with 10 additions and 3 deletions

View file

@ -62,7 +62,6 @@ buildDotnetModule rec {
description = ".NET C# and Visual Basic compiler";
homepage = "https://github.com/dotnet/roslyn";
mainProgram = "csc";
platforms = platforms.linux;
license = licenses.mit;
maintainers = with maintainers; [ corngood ];
};

View file

@ -21,6 +21,8 @@ let
</configuration>
'';
inherit (stdenv.hostPlatform.extensions) sharedLibrary;
in
stdenv.mkDerivation rec {
@ -78,12 +80,18 @@ stdenv.mkDerivation rec {
mv artifacts/msbuild artifacts/mono-msbuild
chmod +x artifacts/mono-msbuild/MSBuild.dll
ln -s $(find ${dotnet-sdk} -name libhostfxr.so) artifacts/mono-msbuild/SdkResolvers/Microsoft.DotNet.MSBuildSdkResolver/
# The provided libhostfxr.dylib is for x86_64-darwin, so we remove it
rm artifacts/mono-msbuild/SdkResolvers/Microsoft.DotNet.MSBuildSdkResolver/libhostfxr.dylib
ln -s $(find ${dotnet-sdk} -name libhostfxr${sharedLibrary}) artifacts/mono-msbuild/SdkResolvers/Microsoft.DotNet.MSBuildSdkResolver/
# overwrite the file
echo "#!${stdenv.shell}" > eng/common/dotnet-install.sh
echo "#!${stdenv.shell}" > mono/build/get_sdk_files.sh
# Prevent msbuild from downloading a new libhostfxr
echo "#!${stdenv.shell}" > mono/build/extract_and_copy_hostfxr.sh
mkdir -p mono/dotnet-overlay/msbuild-bin
cp ${dotnet-sdk}/sdk/*/{Microsoft.NETCoreSdk.BundledVersions.props,RuntimeIdentifierGraph.json} mono/dotnet-overlay/msbuild-bin
@ -102,7 +110,7 @@ stdenv.mkDerivation rec {
--set-default MONO_GC_PARAMS "nursery-size=64m" \
--add-flags "$out/lib/mono/msbuild/15.0/bin/MSBuild.dll"
ln -s $(find ${dotnet-sdk} -name libhostfxr.so) $out/lib/mono/msbuild/Current/bin/SdkResolvers/Microsoft.DotNet.MSBuildSdkResolver/
ln -s $(find ${dotnet-sdk} -name libhostfxr${sharedLibrary}) $out/lib/mono/msbuild/Current/bin/SdkResolvers/Microsoft.DotNet.MSBuildSdkResolver/
'';
doInstallCheck = true;