diff options
-rw-r--r-- | doc/languages-frameworks/dotnet.section.md | 2 | ||||
-rw-r--r-- | pkgs/build-support/build-dotnet-module/default.nix | 11 |
2 files changed, 7 insertions, 6 deletions
diff --git a/doc/languages-frameworks/dotnet.section.md b/doc/languages-frameworks/dotnet.section.md index 159347008e80c..88e1a0b295968 100644 --- a/doc/languages-frameworks/dotnet.section.md +++ b/doc/languages-frameworks/dotnet.section.md @@ -90,7 +90,7 @@ To package Dotnet applications, you can use `buildDotnetModule`. This has simila * `dotnet-sdk` is useful in cases where you need to change what dotnet SDK is being used. * `dotnet-runtime` is useful in cases where you need to change what dotnet runtime is being used. This can be either a regular dotnet runtime, or an aspnetcore. * `dotnet-test-sdk` is useful in cases where unit tests expect a different dotnet SDK. By default, this is set to the `dotnet-sdk` attribute. -* `testProjectFile` is useful in cases where the regular project file does not contain the unit tests. By default, this is set to the `projectFile` attribute. +* `testProjectFile` is useful in cases where the regular project file does not contain the unit tests. It gets restored and build, but not installed. You may need to regenerate your nuget lockfile after setting this. * `disabledTests` is used to disable running specific unit tests. This gets passed as: `dotnet test --filter "FullyQualifiedName!={}"`, to ensure compatibility with all unit test frameworks. * `dotnetRestoreFlags` can be used to pass flags to `dotnet restore`. * `dotnetBuildFlags` can be used to pass flags to `dotnet build`. diff --git a/pkgs/build-support/build-dotnet-module/default.nix b/pkgs/build-support/build-dotnet-module/default.nix index b0b41dc59cf02..6976ac6781a16 100644 --- a/pkgs/build-support/build-dotnet-module/default.nix +++ b/pkgs/build-support/build-dotnet-module/default.nix @@ -46,8 +46,9 @@ # Tests to disable. This gets passed to `dotnet test --filter "FullyQualifiedName!={}"`, to ensure compatibility with all frameworks. # See https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test#filter-option-details for more details. , disabledTests ? [] -# The project file to run unit tests against. This is usually the regular project file, but sometimes it needs to be manually set. -, testProjectFile ? projectFile +# The project file to run unit tests against. This is usually referenced in the regular project file, but sometimes it needs to be manually set. +# It gets restored and build, but not installed. You may need to regenerate your nuget lockfile after setting this. +, testProjectFile ? "" # The type of build to perform. This is passed to `dotnet` with the `--configuration` flag. Possible values are `Release`, `Debug`, etc. , buildType ? "Release" @@ -136,7 +137,7 @@ let mkdir -p "$HOME/nuget_pkgs" - for project in "${lib.concatStringsSep "\" \"" (lib.toList projectFile)}"; do + for project in "${lib.concatStringsSep "\" \"" ((lib.toList projectFile) ++ lib.optionals (testProjectFile != "") (lib.toList testProjectFile))}"; do ${dotnet-sdk}/bin/dotnet restore "$project" \ ${lib.optionalString (!enableParallelBuilding) "--disable-parallel"} \ -p:ContinuousIntegrationBuild=true \ @@ -156,7 +157,7 @@ let export HOME=$(mktemp -d) - for project in ''${projectFile[@]}; do + for project in ''${projectFile[@]} ''${testProjectFile[@]}; do dotnet restore "$project" \ ${lib.optionalString (!enableParallelBuilding) "--disable-parallel"} \ -p:ContinuousIntegrationBuild=true \ @@ -172,7 +173,7 @@ let buildPhase = args.buildPhase or '' runHook preBuild - for project in ''${projectFile[@]}; do + for project in ''${projectFile[@]} ''${testProjectFile[@]}; do dotnet build "$project" \ -maxcpucount:${if enableParallelBuilding then "$NIX_BUILD_CORES" else "1"} \ -p:BuildInParallel=${if enableParallelBuilding then "true" else "false"} \ |