nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
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{
6 lib,
7 dotnet-sdk,
8 buildPackages, # buildDotnetModule
9 runCommand,
10}:
11
12let
13 inherit (buildPackages) buildDotnetModule;
14
15 nugetDeps = ./nuget-deps.json;
16
17 # Specify the TargetFramework via an environment variable so that we don't
18 # have to update the .csproj files when updating dotnet-sdk
19 TargetFramework = "net${lib.versions.majorMinor (lib.getVersion dotnet-sdk)}";
20
21 library = buildDotnetModule {
22 name = "project-references-test-library";
23 src = ./library;
24 inherit nugetDeps;
25 env.TargetFramework = TargetFramework;
26
27 packNupkg = true;
28 };
29
30 application = buildDotnetModule {
31 name = "project-references-test-application";
32 src = ./application;
33 inherit nugetDeps;
34 env.TargetFramework = TargetFramework;
35
36 projectReferences = [ library ];
37 };
38in
39
40runCommand "project-references-test" { } ''
41 ${application}/bin/Application
42 mkdir $out
43''