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