2021-01-24 00:40:18 +00:00
|
|
|
{ lib, stdenv, dotnetfx }:
|
2010-06-15 11:16:35 +00:00
|
|
|
{ name
|
|
|
|
, src
|
|
|
|
, baseDir ? "."
|
|
|
|
, slnFile
|
|
|
|
, targets ? "ReBuild"
|
|
|
|
, verbosity ? "detailed"
|
|
|
|
, options ? "/p:Configuration=Debug;Platform=Win32"
|
|
|
|
, assemblyInputs ? []
|
|
|
|
, preBuild ? ""
|
2011-09-13 15:47:54 +00:00
|
|
|
, modifyPublicMain ? false
|
2011-09-13 12:17:04 +00:00
|
|
|
, mainClassFile ? null
|
2010-06-15 11:16:35 +00:00
|
|
|
}:
|
|
|
|
|
2011-09-13 15:47:54 +00:00
|
|
|
assert modifyPublicMain -> mainClassFile != null;
|
2011-09-13 12:17:04 +00:00
|
|
|
|
2010-06-15 11:16:35 +00:00
|
|
|
stdenv.mkDerivation {
|
2011-09-13 12:17:04 +00:00
|
|
|
inherit name src;
|
2020-09-20 22:30:58 +00:00
|
|
|
|
|
|
|
buildInputs = [ dotnetfx ];
|
2011-09-13 12:17:04 +00:00
|
|
|
|
2010-06-15 11:16:35 +00:00
|
|
|
preConfigure = ''
|
|
|
|
cd ${baseDir}
|
|
|
|
'';
|
2020-09-20 22:30:58 +00:00
|
|
|
|
2011-09-13 12:17:04 +00:00
|
|
|
preBuild = ''
|
2021-01-24 00:40:18 +00:00
|
|
|
${lib.optionalString modifyPublicMain ''
|
2011-09-13 15:47:54 +00:00
|
|
|
sed -i -e "s|static void Main|public static void Main|" ${mainClassFile}
|
2011-09-13 12:17:04 +00:00
|
|
|
''}
|
2011-09-13 15:47:54 +00:00
|
|
|
${preBuild}
|
2011-09-13 12:17:04 +00:00
|
|
|
'';
|
2020-09-20 22:30:58 +00:00
|
|
|
|
2011-09-13 21:07:08 +00:00
|
|
|
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"
|
2020-09-20 22:30:58 +00:00
|
|
|
|
2011-09-13 21:07:08 +00:00
|
|
|
addDeps $i
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
2020-09-20 22:30:58 +00:00
|
|
|
|
2010-06-15 11:16:35 +00:00
|
|
|
for i in ${toString assemblyInputs}
|
|
|
|
do
|
2020-09-20 22:30:58 +00:00
|
|
|
windowsPath=$(cygpath --windows $i)
|
2010-06-15 11:16:35 +00:00
|
|
|
echo "Using assembly path: $windowsPath"
|
2020-09-20 22:30:58 +00:00
|
|
|
|
2010-06-15 11:16:35 +00:00
|
|
|
if [ "$assemblySearchPaths" = "" ]
|
|
|
|
then
|
|
|
|
assemblySearchPaths="$windowsPath"
|
|
|
|
else
|
|
|
|
assemblySearchPaths="$assemblySearchPaths;$windowsPath"
|
|
|
|
fi
|
2020-09-20 22:30:58 +00:00
|
|
|
|
2011-09-13 21:07:08 +00:00
|
|
|
addDeps $i
|
2010-06-15 11:16:35 +00:00
|
|
|
done
|
2020-09-20 22:30:58 +00:00
|
|
|
|
2010-06-15 11:16:35 +00:00
|
|
|
echo "Assembly search paths are: $assemblySearchPaths"
|
2020-09-20 22:30:58 +00:00
|
|
|
|
2010-06-15 11:16:35 +00:00
|
|
|
if [ "$assemblySearchPaths" != "" ]
|
|
|
|
then
|
|
|
|
echo "Using assembly search paths args: $assemblySearchPathsArg"
|
|
|
|
export AssemblySearchPaths=$assemblySearchPaths
|
|
|
|
fi
|
2020-09-20 22:30:58 +00:00
|
|
|
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p $out
|
2010-07-12 11:18:11 +00:00
|
|
|
MSBuild.exe ${toString slnFile} /nologo /t:${targets} /p:IntermediateOutputPath=$(cygpath --windows $out)\\ /p:OutputPath=$(cygpath --windows $out)\\ /verbosity:${verbosity} ${options}
|
2020-09-20 22:30:58 +00:00
|
|
|
|
2011-09-13 15:47:54 +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.
|
2020-09-20 22:30:58 +00:00
|
|
|
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p $out/nix-support
|
2020-09-20 22:30:58 +00:00
|
|
|
|
2011-09-13 15:47:54 +00:00
|
|
|
for i in ${toString assemblyInputs}
|
|
|
|
do
|
|
|
|
echo $i >> $out/nix-support/dotnet-assemblies
|
|
|
|
done
|
2010-06-15 11:16:35 +00:00
|
|
|
'';
|
|
|
|
}
|