diff options
author | Raphael Robatsch <raphael-git@tapesoftware.net> | 2023-05-26 10:40:36 +0000 |
---|---|---|
committer | Raphael Robatsch <raphael-git@tapesoftware.net> | 2023-05-26 16:18:07 +0200 |
commit | 256c3a7a534106cfc441c88b97c4514793bccda3 (patch) | |
tree | e4a7cd8a057f74946a6ca22d70b08d3e1edcf338 | |
parent | c9ff452fd28bbe3fe44fa0f6a7154b8926645540 (diff) |
tests.dotnet: init with test for projectReferences
Add a test for buildDotnetModule's `projectReferences = [ ... ];` feature, which is currently unused and therefore untested in nixpkgs.
-rw-r--r-- | pkgs/test/default.nix | 2 | ||||
-rw-r--r-- | pkgs/test/dotnet/default.nix | 5 | ||||
-rw-r--r-- | pkgs/test/dotnet/project-references/application/Application.cs | 1 | ||||
-rw-r--r-- | pkgs/test/dotnet/project-references/application/Application.csproj | 10 | ||||
-rw-r--r-- | pkgs/test/dotnet/project-references/default.nix | 38 | ||||
-rw-r--r-- | pkgs/test/dotnet/project-references/library/Library.cs | 8 | ||||
-rw-r--r-- | pkgs/test/dotnet/project-references/library/Library.csproj | 5 | ||||
-rw-r--r-- | pkgs/test/dotnet/project-references/nuget-deps.nix | 5 |
8 files changed, 74 insertions, 0 deletions
diff --git a/pkgs/test/default.nix b/pkgs/test/default.nix index 9f684dcea72ff..b6793d25b6e21 100644 --- a/pkgs/test/default.nix +++ b/pkgs/test/default.nix @@ -86,6 +86,8 @@ with pkgs; coq = callPackage ./coq {}; + dotnet = recurseIntoAttrs (callPackages ./dotnet { }); + makeHardcodeGsettingsPatch = callPackage ./make-hardcode-gsettings-patch { }; makeWrapper = callPackage ./make-wrapper { }; diff --git a/pkgs/test/dotnet/default.nix b/pkgs/test/dotnet/default.nix new file mode 100644 index 0000000000000..7592b09d76e3c --- /dev/null +++ b/pkgs/test/dotnet/default.nix @@ -0,0 +1,5 @@ +{ callPackage }: + +{ + project-references = callPackage ./project-references { }; +} diff --git a/pkgs/test/dotnet/project-references/application/Application.cs b/pkgs/test/dotnet/project-references/application/Application.cs new file mode 100644 index 0000000000000..ae2c956a4df73 --- /dev/null +++ b/pkgs/test/dotnet/project-references/application/Application.cs @@ -0,0 +1 @@ +ProjectReferencesTest.Library.Hello(); diff --git a/pkgs/test/dotnet/project-references/application/Application.csproj b/pkgs/test/dotnet/project-references/application/Application.csproj new file mode 100644 index 0000000000000..6507637a5535c --- /dev/null +++ b/pkgs/test/dotnet/project-references/application/Application.csproj @@ -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> 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 +'' diff --git a/pkgs/test/dotnet/project-references/library/Library.cs b/pkgs/test/dotnet/project-references/library/Library.cs new file mode 100644 index 0000000000000..a4af4a0fea2d5 --- /dev/null +++ b/pkgs/test/dotnet/project-references/library/Library.cs @@ -0,0 +1,8 @@ +namespace ProjectReferencesTest; +public static class Library +{ + public static void Hello() + { + System.Console.WriteLine("Hello, World!"); + } +} diff --git a/pkgs/test/dotnet/project-references/library/Library.csproj b/pkgs/test/dotnet/project-references/library/Library.csproj new file mode 100644 index 0000000000000..b9a71276d24a9 --- /dev/null +++ b/pkgs/test/dotnet/project-references/library/Library.csproj @@ -0,0 +1,5 @@ +<Project Sdk="Microsoft.NET.Sdk"> + <PropertyGroup> + <PackageId>ProjectReferencesTest.Library</PackageId> + </PropertyGroup> +</Project> diff --git a/pkgs/test/dotnet/project-references/nuget-deps.nix b/pkgs/test/dotnet/project-references/nuget-deps.nix new file mode 100644 index 0000000000000..f3a17967e25c8 --- /dev/null +++ b/pkgs/test/dotnet/project-references/nuget-deps.nix @@ -0,0 +1,5 @@ +# This file was automatically generated by passthru.fetch-deps. +# Please dont edit it manually, your changes might get overwritten! + +{ fetchNuGet }: [ +] |