dotnet-sdk-setup-hook: add nuget.org as a package source when there is no <clear/>

This commit is contained in:
js6pak
2024-12-23 03:51:45 +01:00
parent 2c8d3f48d3
commit 86b2ae1989
3 changed files with 7 additions and 18 deletions

View File

@@ -27,12 +27,6 @@ buildDotnetModule rec {
projectFile = "UI.Avalonia/UI.Avalonia.csproj";
nugetDeps = ./deps.json;
preConfigureNuGet = ''
# This should really be in the upstream nuget.config
dotnet nuget add source https://api.nuget.org/v3/index.json \
-n nuget.org --configfile nuget.config
'';
runtimeDeps = [
zlib
openssl

View File

@@ -1,22 +1,12 @@
{
lib,
openssl,
writeText,
git,
buildDotnetModule,
dotnetCorePackages,
fetchFromGitHub,
testers,
}:
let
nuget-config = writeText "nuget.config" ''
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
'';
in
buildDotnetModule (finalAttrs: {
pname = "recyclarr";
version = "7.4.1";
@@ -47,8 +37,6 @@ buildDotnetModule (finalAttrs: {
enableParallelBuilding = false;
dotnetRestoreFlags = [ "--configfile=${nuget-config}" ];
doCheck = false;
dotnet-sdk = dotnetCorePackages.sdk_9_0;

View File

@@ -85,6 +85,7 @@ configureNuget() {
rootConfig=$(find . -maxdepth 1 -iname nuget.config -print -quit)
if [[ -z $rootConfig ]]; then
dotnet new nugetconfig
rootConfig=nuget.config
fi
(
@@ -100,6 +101,12 @@ configureNuget() {
-i /configuration/packageSources/__new -t attr -n value -v "$nugetSource"
-r /configuration/packageSources/__new -v add)
if [[ -n ${keepNugetConfig-} ]] &&
! @xmlstarlet@/bin/xmlstarlet select -t -i "/configuration/packageSources/clear" -nl "$rootConfig" &&
! @xmlstarlet@/bin/xmlstarlet select -t -i "/configuration/packageSources/add[@value='https://api.nuget.org/v3/index.json' or @key='nuget.org']" -nl "$rootConfig"; then
dotnet nuget add source https://api.nuget.org/v3/index.json --name nuget.org --configfile "$rootConfig"
fi
if [[ -z ${keepNugetConfig-} ]]; then
xmlConfigArgs+=(-d '//configuration/*')
xmlRootConfigArgs+=("${xmlSourceConfigArgs[@]}")