tests.dotnet: init with test for projectReferences

Add a test for buildDotnetModule's `projectReferences = [ ... ];`
feature, which is currently unused and therefore untested in nixpkgs.
This commit is contained in:
Raphael Robatsch 2023-05-26 10:40:36 +00:00
parent c9ff452fd2
commit 256c3a7a53
8 changed files with 74 additions and 0 deletions

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 }: [
]