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

buildDotnetModule: fix `projectReferences = [ ... ]`

authored by Sandro and committed by GitHub 6b942b50 f45bee3f

+78 -6
+4 -6
pkgs/build-support/dotnet/make-nuget-source/default.nix
··· 15 15 buildCommand = '' 16 16 mkdir -p $out/{lib,share} 17 17 18 - ( 19 - shopt -s nullglob 20 - for nupkg in ${lib.concatMapStringsSep " " (dep: "\"${dep}\"/*.nupkg") deps}; do 21 - cp --no-clobber "$nupkg" $out/lib 22 - done 23 - ) 18 + # use -L to follow symbolic links. When `projectReferences` is used in 19 + # buildDotnetModule, one of the deps will be a symlink farm. 20 + find -L ${lib.concatStringsSep " " deps} -type f -name '*.nupkg' -exec \ 21 + cp --no-clobber '{}' $out/lib ';' 24 22 25 23 # Generates a list of all licenses' spdx ids, if available. 26 24 # Note that this currently ignores any license provided in plain text (e.g. "LICENSE.txt")
+2
pkgs/test/default.nix
··· 86 86 87 87 coq = callPackage ./coq {}; 88 88 89 + dotnet = recurseIntoAttrs (callPackages ./dotnet { }); 90 + 89 91 makeHardcodeGsettingsPatch = callPackage ./make-hardcode-gsettings-patch { }; 90 92 91 93 makeWrapper = callPackage ./make-wrapper { };
+5
pkgs/test/dotnet/default.nix
··· 1 + { callPackage }: 2 + 3 + { 4 + project-references = callPackage ./project-references { }; 5 + }
+1
pkgs/test/dotnet/project-references/application/Application.cs
··· 1 + ProjectReferencesTest.Library.Hello();
+10
pkgs/test/dotnet/project-references/application/Application.csproj
··· 1 + <Project Sdk="Microsoft.NET.Sdk"> 2 + <PropertyGroup> 3 + <OutputType>exe</OutputType> 4 + </PropertyGroup> 5 + 6 + <ItemGroup> 7 + <ProjectReference Include="../library/Library.csproj" /> 8 + <PackageReference Include="ProjectReferencesTest.Library" Version="*" Condition=" '$(ContinuousIntegrationBuild)'=='true' " /> 9 + </ItemGroup> 10 + </Project>
+38
pkgs/test/dotnet/project-references/default.nix
··· 1 + # Tests the `projectReferences = [ ... ];` feature of buildDotnetModule. 2 + # The `library` derivation exposes a .nupkg, which is then consumed by the `application` derivation. 3 + # https://nixos.org/manual/nixpkgs/unstable/index.html#packaging-a-dotnet-application 4 + 5 + { lib 6 + , dotnet-sdk 7 + , buildDotnetModule 8 + , runCommand 9 + }: 10 + 11 + let 12 + nugetDeps = ./nuget-deps.nix; 13 + 14 + # Specify the TargetFramework via an environment variable so that we don't 15 + # have to update the .csproj files when updating dotnet-sdk 16 + TargetFramework = "net${lib.versions.majorMinor (lib.getVersion dotnet-sdk)}"; 17 + 18 + library = buildDotnetModule { 19 + name = "project-references-test-library"; 20 + src = ./library; 21 + inherit nugetDeps TargetFramework; 22 + 23 + packNupkg = true; 24 + }; 25 + 26 + application = buildDotnetModule { 27 + name = "project-references-test-application"; 28 + src = ./application; 29 + inherit nugetDeps TargetFramework; 30 + 31 + projectReferences = [ library ]; 32 + }; 33 + in 34 + 35 + runCommand "project-references-test" { } '' 36 + ${application}/bin/Application 37 + touch $out 38 + ''
+8
pkgs/test/dotnet/project-references/library/Library.cs
··· 1 + namespace ProjectReferencesTest; 2 + public static class Library 3 + { 4 + public static void Hello() 5 + { 6 + System.Console.WriteLine("Hello, World!"); 7 + } 8 + }
+5
pkgs/test/dotnet/project-references/library/Library.csproj
··· 1 + <Project Sdk="Microsoft.NET.Sdk"> 2 + <PropertyGroup> 3 + <PackageId>ProjectReferencesTest.Library</PackageId> 4 + </PropertyGroup> 5 + </Project>
+5
pkgs/test/dotnet/project-references/nuget-deps.nix
··· 1 + # This file was automatically generated by passthru.fetch-deps. 2 + # Please dont edit it manually, your changes might get overwritten! 3 + 4 + { fetchNuGet }: [ 5 + ]