Merge pull request #258184 from mdarocha/dotnet-fixes
buildDotnetModule small improvements
This commit is contained in:
@@ -138,7 +138,9 @@ in buildDotnetModule rec {
|
|||||||
src = ./.;
|
src = ./.;
|
||||||
|
|
||||||
projectFile = "src/project.sln";
|
projectFile = "src/project.sln";
|
||||||
nugetDeps = ./deps.nix; # File generated with `nix-build -A package.passthru.fetch-deps`.
|
# File generated with `nix-build -A package.passthru.fetch-deps`.
|
||||||
|
# To run fetch-deps when this file does not yet exist, set nugetDeps to null
|
||||||
|
nugetDeps = ./deps.nix;
|
||||||
|
|
||||||
projectReferences = [ referencedProject ]; # `referencedProject` must contain `nupkg` in the folder structure.
|
projectReferences = [ referencedProject ]; # `referencedProject` must contain `nupkg` in the folder structure.
|
||||||
|
|
||||||
|
|||||||
@@ -158,6 +158,22 @@ stdenvNoCC.mkDerivation (args // {
|
|||||||
dotnet-sdk
|
dotnet-sdk
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# Parse the version attr into a format acceptable for the Version msbuild property
|
||||||
|
# The actual version attr is saved in InformationalVersion, which accepts an arbitrary string
|
||||||
|
versionForDotnet = if !(lib.hasAttr "version" args) || args.version == null
|
||||||
|
then null else let
|
||||||
|
components = lib.pipe args.version [
|
||||||
|
lib.splitVersion
|
||||||
|
(lib.filter (x: (lib.strings.match "[0-9]+" x) != null))
|
||||||
|
(lib.filter (x: (lib.toInt x) < 65535)) # one version component in dotnet has to fit in 16 bits
|
||||||
|
];
|
||||||
|
in if (lib.length components) == 0
|
||||||
|
then null
|
||||||
|
else lib.concatStringsSep "." ((lib.take 4 components)
|
||||||
|
++ (if (lib.length components) < 4
|
||||||
|
then lib.replicate (4 - (lib.length components)) "0"
|
||||||
|
else [ ]));
|
||||||
|
|
||||||
makeWrapperArgs = args.makeWrapperArgs or [ ] ++ [
|
makeWrapperArgs = args.makeWrapperArgs or [ ] ++ [
|
||||||
"--prefix LD_LIBRARY_PATH : ${dotnet-sdk.icu}/lib"
|
"--prefix LD_LIBRARY_PATH : ${dotnet-sdk.icu}/lib"
|
||||||
];
|
];
|
||||||
@@ -172,7 +188,7 @@ stdenvNoCC.mkDerivation (args // {
|
|||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
inherit nuget-source;
|
inherit nuget-source;
|
||||||
} // lib.optionalAttrs (nugetDepsFile != null) {
|
} // lib.optionalAttrs (!lib.isDerivation nugetDeps) {
|
||||||
fetch-deps =
|
fetch-deps =
|
||||||
let
|
let
|
||||||
flags = dotnetFlags ++ dotnetRestoreFlags;
|
flags = dotnetFlags ++ dotnetRestoreFlags;
|
||||||
|
|||||||
@@ -24,8 +24,13 @@ dotnetBuildHook() {
|
|||||||
dotnetBuildFlags+=("-p:UseAppHost=true")
|
dotnetBuildFlags+=("-p:UseAppHost=true")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local versionFlags=()
|
||||||
if [ "${version-}" ]; then
|
if [ "${version-}" ]; then
|
||||||
local -r versionFlag="-p:Version=${version-}"
|
versionFlags+=("-p:InformationalVersion=${version-}")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${versionForDotnet-}" ]; then
|
||||||
|
versionFlags+=("-p:Version=${versionForDotnet-}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
dotnetBuild() {
|
dotnetBuild() {
|
||||||
@@ -43,7 +48,7 @@ dotnetBuildHook() {
|
|||||||
-p:Deterministic=true \
|
-p:Deterministic=true \
|
||||||
--configuration "@buildType@" \
|
--configuration "@buildType@" \
|
||||||
--no-restore \
|
--no-restore \
|
||||||
${versionFlag-} \
|
${versionFlags[@]} \
|
||||||
${runtimeIdFlags[@]} \
|
${runtimeIdFlags[@]} \
|
||||||
${dotnetBuildFlags[@]} \
|
${dotnetBuildFlags[@]} \
|
||||||
${dotnetFlags[@]}
|
${dotnetFlags[@]}
|
||||||
|
|||||||
Reference in New Issue
Block a user