2024-05-13 21:24:10 +00:00
|
|
|
{ dotnetenv }:
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-05-13 21:24:10 +00:00
|
|
|
{ name, src, baseDir ? ".", slnFile, targets ? "ReBuild", verbosity ? "detailed"
|
|
|
|
, options ? "/p:Configuration=Debug;Platform=Win32", assemblyInputs ? [ ]
|
|
|
|
, preBuild ? "", namespace, mainClassName, mainClassFile
|
|
|
|
, modifyPublicMain ? true }:
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
application = dotnetenv.buildSolution {
|
|
|
|
inherit name src baseDir slnFile targets verbosity;
|
|
|
|
inherit options assemblyInputs preBuild;
|
|
|
|
inherit modifyPublicMain mainClassFile;
|
|
|
|
};
|
2024-05-13 21:24:10 +00:00
|
|
|
in dotnetenv.buildSolution {
|
2024-05-02 00:46:19 +00:00
|
|
|
name = "${name}-wrapper";
|
|
|
|
src = ./Wrapper;
|
|
|
|
slnFile = "Wrapper.sln";
|
|
|
|
assemblyInputs = [ application ];
|
|
|
|
preBuild = ''
|
2024-05-13 21:24:10 +00:00
|
|
|
addRuntimeDeps()
|
|
|
|
{
|
|
|
|
if [ -f $1/nix-support/dotnet-assemblies ]
|
|
|
|
then
|
|
|
|
for i in $(cat $1/nix-support/dotnet-assemblies)
|
|
|
|
do
|
|
|
|
windowsPath=$(cygpath --windows $i | sed 's|\\|\\\\|g')
|
|
|
|
assemblySearchArray="$assemblySearchArray @\"$windowsPath\""
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-05-13 21:24:10 +00:00
|
|
|
addRuntimeDeps $i
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-05-13 21:24:10 +00:00
|
|
|
export exePath=$(cygpath --windows $(find ${application} -name \*.exe) | sed 's|\\|\\\\|g')
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-05-13 21:24:10 +00:00
|
|
|
# Generate assemblySearchPaths string array contents
|
|
|
|
for path in ${toString assemblyInputs}
|
|
|
|
do
|
|
|
|
assemblySearchArray="$assemblySearchArray @\"$(cygpath --windows $path | sed 's|\\|\\\\|g')\", "
|
|
|
|
addRuntimeDeps $path
|
|
|
|
done
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-05-13 21:24:10 +00:00
|
|
|
sed -e "s|@ROOTNAMESPACE@|${namespace}Wrapper|" \
|
|
|
|
-e "s|@ASSEMBLYNAME@|${namespace}|" \
|
|
|
|
Wrapper/Wrapper.csproj.in > Wrapper/Wrapper.csproj
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-05-13 21:24:10 +00:00
|
|
|
sed -e "s|@NAMESPACE@|${namespace}|g" \
|
|
|
|
-e "s|@MAINCLASSNAME@|${mainClassName}|g" \
|
|
|
|
-e "s|@EXEPATH@|$exePath|g" \
|
|
|
|
-e "s|@ASSEMBLYSEARCHPATH@|$assemblySearchArray|" \
|
|
|
|
Wrapper/Wrapper.cs.in > Wrapper/Wrapper.cs
|
2024-05-02 00:46:19 +00:00
|
|
|
'';
|
|
|
|
}
|