Merge pull request #234235 from raphaelr/mknugetsource-support-subdirs

buildDotnetModule: fix `projectReferences = [ ... ]`
This commit is contained in:
Sandro 2023-06-14 20:12:03 +02:00 committed by GitHub
commit 6b942b501e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 78 additions and 6 deletions

View file

@ -15,12 +15,10 @@ let
buildCommand = ''
mkdir -p $out/{lib,share}
(
shopt -s nullglob
for nupkg in ${lib.concatMapStringsSep " " (dep: "\"${dep}\"/*.nupkg") deps}; do
cp --no-clobber "$nupkg" $out/lib
done
)
# use -L to follow symbolic links. When `projectReferences` is used in
# buildDotnetModule, one of the deps will be a symlink farm.
find -L ${lib.concatStringsSep " " deps} -type f -name '*.nupkg' -exec \
cp --no-clobber '{}' $out/lib ';'
# Generates a list of all licenses' spdx ids, if available.
# Note that this currently ignores any license provided in plain text (e.g. "LICENSE.txt")

View file

@ -86,6 +86,8 @@ with pkgs;
coq = callPackage ./coq {};
dotnet = recurseIntoAttrs (callPackages ./dotnet { });
makeHardcodeGsettingsPatch = callPackage ./make-hardcode-gsettings-patch { };
makeWrapper = callPackage ./make-wrapper { };

View file

@ -0,0 +1,5 @@
{ callPackage }:
{
project-references = callPackage ./project-references { };
}

View file

@ -0,0 +1 @@
ProjectReferencesTest.Library.Hello();

View file

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>exe</OutputType>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="../library/Library.csproj" />
<PackageReference Include="ProjectReferencesTest.Library" Version="*" Condition=" '$(ContinuousIntegrationBuild)'=='true' " />
</ItemGroup>
</Project>

View file

@ -0,0 +1,38 @@
# Tests the `projectReferences = [ ... ];` feature of buildDotnetModule.
# The `library` derivation exposes a .nupkg, which is then consumed by the `application` derivation.
# https://nixos.org/manual/nixpkgs/unstable/index.html#packaging-a-dotnet-application
{ lib
, dotnet-sdk
, buildDotnetModule
, runCommand
}:
let
nugetDeps = ./nuget-deps.nix;
# Specify the TargetFramework via an environment variable so that we don't
# have to update the .csproj files when updating dotnet-sdk
TargetFramework = "net${lib.versions.majorMinor (lib.getVersion dotnet-sdk)}";
library = buildDotnetModule {
name = "project-references-test-library";
src = ./library;
inherit nugetDeps TargetFramework;
packNupkg = true;
};
application = buildDotnetModule {
name = "project-references-test-application";
src = ./application;
inherit nugetDeps TargetFramework;
projectReferences = [ library ];
};
in
runCommand "project-references-test" { } ''
${application}/bin/Application
touch $out
''

View file

@ -0,0 +1,8 @@
namespace ProjectReferencesTest;
public static class Library
{
public static void Hello()
{
System.Console.WriteLine("Hello, World!");
}
}

View file

@ -0,0 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>ProjectReferencesTest.Library</PackageId>
</PropertyGroup>
</Project>

View file

@ -0,0 +1,5 @@
# This file was automatically generated by passthru.fetch-deps.
# Please dont edit it manually, your changes might get overwritten!
{ fetchNuGet }: [
]