dotnet: fix problems with --runtime flags (#432571)

This commit is contained in:
David McFarland
2025-08-20 13:28:25 -03:00
committed by GitHub
2 changed files with 52 additions and 16 deletions
@@ -9,6 +9,14 @@
callPackage,
}:
let
plugins = [
"ArchiSteamFarm.OfficialPlugins.ItemsMatcher"
"ArchiSteamFarm.OfficialPlugins.MobileAuthenticator"
"ArchiSteamFarm.OfficialPlugins.Monitoring"
"ArchiSteamFarm.OfficialPlugins.SteamTokenDumper"
];
in
buildDotnetModule rec {
pname = "ArchiSteamFarm";
# nixpkgs-update: no auto update
@@ -26,7 +34,12 @@ buildDotnetModule rec {
nugetDeps = ./deps.json;
projectFile = "ArchiSteamFarm.sln";
projectFile = [
"ArchiSteamFarm"
]
++ plugins;
testProjectFile = "ArchiSteamFarm.Tests";
executable = "ArchiSteamFarm";
enableParallelBuilding = false;
@@ -50,7 +63,7 @@ buildDotnetModule rec {
doCheck = true;
preInstall = ''
installPhase = ''
dotnetProjectFiles=(ArchiSteamFarm)
# A mutable path, with this directory tree must be set. By default, this would point at the nix store causing errors.
@@ -58,20 +71,19 @@ buildDotnetModule rec {
--run 'mkdir -p ~/.config/archisteamfarm/{config,logs,plugins}'
--set "ASF_PATH" "~/.config/archisteamfarm"
)
'';
postInstall = ''
dotnetInstallPhase
buildPlugin() {
echo "Publishing plugin $1"
dotnet publish $1 -p:ContinuousIntegrationBuild=true -p:Deterministic=true \
--output $out/lib/ArchiSteamFarm/plugins/$1 --configuration Release \
$dotnetFlags $dotnetInstallFlags
dotnetProjectFiles=("$1")
dotnetInstallPath="$out/lib/ArchiSteamFarm/plugins/$1"
dotnetInstallPhase
}
buildPlugin ArchiSteamFarm.OfficialPlugins.ItemsMatcher
buildPlugin ArchiSteamFarm.OfficialPlugins.MobileAuthenticator
buildPlugin ArchiSteamFarm.OfficialPlugins.Monitoring
buildPlugin ArchiSteamFarm.OfficialPlugins.SteamTokenDumper
''
+ lib.concatMapStrings (p: "buildPlugin ${p}\n") plugins
+ ''
chmod +x $out/lib/ArchiSteamFarm/ArchiSteamFarm.dll
wrapDotnetProgram $out/lib/ArchiSteamFarm/ArchiSteamFarm.dll $out/bin/ArchiSteamFarm
@@ -1,5 +1,9 @@
# shellcheck shell=bash
_dotnetIsSolution() {
dotnet sln ${1:+"$1"} list 2>/dev/null
}
dotnetConfigurePhase() {
echo "Executing dotnetConfigureHook"
@@ -108,9 +112,12 @@ dotnetBuildPhase() {
dotnetBuild() {
local -r projectFile="${1-}"
local useRuntime=
_dotnetIsSolution "$projectFile" || useRuntime=1
for runtimeId in "${runtimeIds[@]}"; do
local runtimeIdFlags=()
if [[ $projectFile == *.csproj || -n ${dotnetSelfContainedBuild-} ]]; then
if [[ -n $useRuntime ]]; then
runtimeIdFlags+=("--runtime" "$runtimeId")
fi
@@ -188,9 +195,12 @@ dotnetCheckPhase() {
local projectFile runtimeId
for projectFile in "${testProjectFiles[@]-${projectFiles[@]}}"; do
local useRuntime=
_dotnetIsSolution "$projectFile" || useRuntime=1
for runtimeId in "${runtimeIds[@]}"; do
local runtimeIdFlags=()
if [[ $projectFile == *.csproj ]]; then
if [[ -n $useRuntime ]]; then
runtimeIdFlags=("--runtime" "$runtimeId")
fi
@@ -356,9 +366,12 @@ dotnetInstallPhase() {
dotnetPublish() {
local -r projectFile="${1-}"
local useRuntime=
_dotnetIsSolution "$projectFile" || useRuntime=1
for runtimeId in "${runtimeIds[@]}"; do
runtimeIdFlags=()
if [[ $projectFile == *.csproj || -n ${dotnetSelfContainedBuild-} ]]; then
local runtimeIdFlags=()
if [[ -n $useRuntime ]]; then
runtimeIdFlags+=("--runtime" "$runtimeId")
fi
@@ -380,7 +393,18 @@ dotnetInstallPhase() {
dotnetPack() {
local -r projectFile="${1-}"
local useRuntime=
_dotnetIsSolution "$projectFile" || useRuntime=1
for runtimeId in "${runtimeIds[@]}"; do
local runtimeIdFlags=()
if [[ -n $useRuntime ]]; then
runtimeIdFlags+=("--runtime" "$runtimeId")
# set RuntimeIdentifier because --runtime is broken:
# https://github.com/dotnet/sdk/issues/13983
runtimeIdFlags+=(-p:RuntimeIdentifier="$runtimeId")
fi
dotnet pack ${1+"$projectFile"} \
-maxcpucount:"$maxCpuFlag" \
-p:ContinuousIntegrationBuild=true \
@@ -390,7 +414,7 @@ dotnetInstallPhase() {
--configuration "$dotnetBuildType" \
--no-restore \
--no-build \
--runtime "$runtimeId" \
"${runtimeIdFlags[@]}" \
"${flags[@]}" \
"${packFlags[@]}"
done