core/pkgs/build-support/dotnet/dotnetenv/build-solution.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

91 lines
2.1 KiB
Nix
Raw Normal View History

2024-05-02 00:46:19 +00:00
{
lib,
stdenv,
dotnetfx,
}:
{
name,
src,
baseDir ? ".",
slnFile,
targets ? "ReBuild",
verbosity ? "detailed",
options ? "/p:Configuration=Debug;Platform=Win32",
assemblyInputs ? [ ],
preBuild ? "",
modifyPublicMain ? false,
mainClassFile ? null,
}:
assert modifyPublicMain -> mainClassFile != null;
stdenv.mkDerivation {
inherit name src;
buildInputs = [ dotnetfx ];
preConfigure = ''
cd ${baseDir}
'';
preBuild = ''
${lib.optionalString modifyPublicMain ''
sed -i -e "s|static void Main|public static void Main|" ${mainClassFile}
''}
${preBuild}
'';
installPhase = ''
addDeps()
{
if [ -f $1/nix-support/dotnet-assemblies ]
then
for i in $(cat $1/nix-support/dotnet-assemblies)
do
windowsPath=$(cygpath --windows $i)
assemblySearchPaths="$assemblySearchPaths;$windowsPath"
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
addDeps $i
done
fi
}
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
for i in ${toString assemblyInputs}
do
windowsPath=$(cygpath --windows $i)
echo "Using assembly path: $windowsPath"
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
if [ "$assemblySearchPaths" = "" ]
then
assemblySearchPaths="$windowsPath"
else
assemblySearchPaths="$assemblySearchPaths;$windowsPath"
fi
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
addDeps $i
done
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
echo "Assembly search paths are: $assemblySearchPaths"
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
if [ "$assemblySearchPaths" != "" ]
then
echo "Using assembly search paths args: $assemblySearchPathsArg"
export AssemblySearchPaths=$assemblySearchPaths
fi
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
mkdir -p $out
MSBuild.exe ${toString slnFile} /nologo /t:${targets} /p:IntermediateOutputPath=$(cygpath --windows $out)\\ /p:OutputPath=$(cygpath --windows $out)\\ /verbosity:${verbosity} ${options}
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
# Because .NET assemblies store strings as UTF-16 internally, we cannot detect
# hashes. Therefore a text files containing the proper paths is created
# We can also use this file the propagate transitive dependencies.
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
mkdir -p $out/nix-support
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
for i in ${toString assemblyInputs}
do
echo $i >> $out/nix-support/dotnet-assemblies
done
'';
}