mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-20 12:29:02 +02:00
buildDotnetModule: parse version before passing it to dotnet
This avoids problems when the Nix version attribute does not fit the format required by .NET
This commit is contained in:
parent
f1cc116e3d
commit
d016404ccd
|
@ -158,6 +158,22 @@ stdenvNoCC.mkDerivation (args // {
|
|||
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 [ ] ++ [
|
||||
"--prefix LD_LIBRARY_PATH : ${dotnet-sdk.icu}/lib"
|
||||
];
|
||||
|
|
|
@ -24,8 +24,13 @@ dotnetBuildHook() {
|
|||
dotnetBuildFlags+=("-p:UseAppHost=true")
|
||||
fi
|
||||
|
||||
local versionFlags=()
|
||||
if [ "${version-}" ]; then
|
||||
local -r versionFlag="-p:Version=${version-}"
|
||||
versionFlags+=("-p:InformationalVersion=${version-}")
|
||||
fi
|
||||
|
||||
if [ "${versionForDotnet-}" ]; then
|
||||
versionFlags+=("-p:Version=${versionForDotnet-}")
|
||||
fi
|
||||
|
||||
dotnetBuild() {
|
||||
|
@ -43,7 +48,7 @@ dotnetBuildHook() {
|
|||
-p:Deterministic=true \
|
||||
--configuration "@buildType@" \
|
||||
--no-restore \
|
||||
${versionFlag-} \
|
||||
${versionFlags[@]} \
|
||||
${runtimeIdFlags[@]} \
|
||||
${dotnetBuildFlags[@]} \
|
||||
${dotnetFlags[@]}
|
||||
|
|
Loading…
Reference in a new issue