lol
at 15.09-beta 88 lines 2.1 kB view raw
1{stdenv, dotnetfx}: 2{ name 3, src 4, baseDir ? "." 5, slnFile 6, targets ? "ReBuild" 7, verbosity ? "detailed" 8, options ? "/p:Configuration=Debug;Platform=Win32" 9, assemblyInputs ? [] 10, preBuild ? "" 11, modifyPublicMain ? false 12, mainClassFile ? null 13}: 14 15assert modifyPublicMain -> mainClassFile != null; 16 17let 18 wrapperCS = ./Wrapper.cs.in; 19in 20stdenv.mkDerivation { 21 inherit name src; 22 23 buildInputs = [ dotnetfx ]; 24 25 preConfigure = '' 26 cd ${baseDir} 27 ''; 28 29 preBuild = '' 30 ${stdenv.lib.optionalString modifyPublicMain '' 31 sed -i -e "s|static void Main|public static void Main|" ${mainClassFile} 32 ''} 33 ${preBuild} 34 ''; 35 36 installPhase = '' 37 addDeps() 38 { 39 if [ -f $1/nix-support/dotnet-assemblies ] 40 then 41 for i in $(cat $1/nix-support/dotnet-assemblies) 42 do 43 windowsPath=$(cygpath --windows $i) 44 assemblySearchPaths="$assemblySearchPaths;$windowsPath" 45 46 addDeps $i 47 done 48 fi 49 } 50 51 for i in ${toString assemblyInputs} 52 do 53 windowsPath=$(cygpath --windows $i) 54 echo "Using assembly path: $windowsPath" 55 56 if [ "$assemblySearchPaths" = "" ] 57 then 58 assemblySearchPaths="$windowsPath" 59 else 60 assemblySearchPaths="$assemblySearchPaths;$windowsPath" 61 fi 62 63 addDeps $i 64 done 65 66 echo "Assembly search paths are: $assemblySearchPaths" 67 68 if [ "$assemblySearchPaths" != "" ] 69 then 70 echo "Using assembly search paths args: $assemblySearchPathsArg" 71 export AssemblySearchPaths=$assemblySearchPaths 72 fi 73 74 mkdir -p $out 75 MSBuild.exe ${toString slnFile} /nologo /t:${targets} /p:IntermediateOutputPath=$(cygpath --windows $out)\\ /p:OutputPath=$(cygpath --windows $out)\\ /verbosity:${verbosity} ${options} 76 77 # Because .NET assemblies store strings as UTF-16 internally, we cannot detect 78 # hashes. Therefore a text files containing the proper paths is created 79 # We can also use this file the propagate transitive dependencies. 80 81 mkdir -p $out/nix-support 82 83 for i in ${toString assemblyInputs} 84 do 85 echo $i >> $out/nix-support/dotnet-assemblies 86 done 87 ''; 88}