about summary refs log tree commit diff
path: root/pkgs/test/dotnet/project-references/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/test/dotnet/project-references/default.nix')
-rw-r--r--pkgs/test/dotnet/project-references/default.nix38
1 files changed, 38 insertions, 0 deletions
diff --git a/pkgs/test/dotnet/project-references/default.nix b/pkgs/test/dotnet/project-references/default.nix
new file mode 100644
index 0000000000000..f40b9196c2091
--- /dev/null
+++ b/pkgs/test/dotnet/project-references/default.nix
@@ -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
+''