buildDotnetModule: fix cross-compilation and remove dotnet-test-sdk

This change fixes cross-compilation for .NET packages (that are not
using .sln as project files). See relevant comment in the change list
for more details.

In addition to that, it removes dotnet-test-sdk that appears to be
broken, that is, dotnet --list-sdks does not recognize SDKs from PATH,
and when propagated from the check hook it was shadowed by inputs from
preceding hooks.

Note that dotnet-test-sdk used to work when it was introduced in PR
144062, but PR 155257 probably overlooked this case. However, currently
it is not used in Nixpkgs and I think dotnetCorePackages.combinePackages
should cover the intended use case for dotnet-test-sdk.
This commit is contained in:
Ivan Trubach 2024-01-09 13:13:08 +03:00
parent 7877140075
commit 0e64e645c9
3 changed files with 1 additions and 10 deletions

View File

@ -117,7 +117,6 @@ For more detail about managing the `deps.nix` file, see [Generating and updating
* `useDotnetFromEnv` will change the binary wrapper so that it uses the .NET from the environment. The runtime specified by `dotnet-runtime` is given as a fallback in case no .NET is installed in the user's environment. This is most useful for .NET global tools and LSP servers, which often extend the .NET CLI and their runtime should match the users' .NET runtime.
* `dotnet-sdk` is useful in cases where you need to change what dotnet SDK is being used. You can also set this to the result of `dotnetSdkPackages.combinePackages`, if the project uses multiple SDKs to build.
* `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. It gets restored and build, but not installed. You may need to regenerate your nuget lockfile after setting this. Note that if set, only tests from this project are executed.
* `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`.

View File

@ -84,8 +84,6 @@
, dotnet-sdk ? dotnetCorePackages.sdk_6_0
# The dotnet runtime to use.
, dotnet-runtime ? dotnetCorePackages.runtime_6_0
# The dotnet SDK to run tests against. This can differentiate from the SDK compiled against.
, dotnet-test-sdk ? dotnet-sdk
, ...
} @ args:
@ -96,7 +94,7 @@ let
else dotnet-sdk.meta.platforms;
inherit (callPackage ./hooks {
inherit dotnet-sdk dotnet-test-sdk disabledTests nuget-source dotnet-runtime runtimeDeps buildType;
inherit dotnet-sdk disabledTests nuget-source dotnet-runtime runtimeDeps buildType;
runtimeId =
if runtimeId != null
then runtimeId

View File

@ -8,7 +8,6 @@
, makeSetupHook
, makeWrapper
, dotnet-sdk
, dotnet-test-sdk
, disabledTests
, nuget-source
, dotnet-runtime
@ -25,7 +24,6 @@ in
dotnetConfigureHook = callPackage ({ }:
makeSetupHook {
name = "dotnet-configure-hook";
propagatedBuildInputs = [ dotnet-sdk nuget-source ];
substitutions = {
nugetSource = nuget-source;
dynamicLinker = "${stdenv.cc}/nix-support/dynamic-linker";
@ -43,7 +41,6 @@ in
dotnetBuildHook = callPackage ({ }:
makeSetupHook {
name = "dotnet-build-hook";
propagatedBuildInputs = [ dotnet-sdk ];
substitutions = {
inherit buildType runtimeId;
};
@ -52,7 +49,6 @@ in
dotnetCheckHook = callPackage ({ }:
makeSetupHook {
name = "dotnet-check-hook";
propagatedBuildInputs = [ dotnet-test-sdk ];
substitutions = {
inherit buildType runtimeId libraryPath;
disabledTests = lib.optionalString (disabledTests != [])
@ -67,7 +63,6 @@ in
dotnetInstallHook = callPackage ({ }:
makeSetupHook {
name = "dotnet-install-hook";
propagatedBuildInputs = [ dotnet-sdk ];
substitutions = {
inherit buildType runtimeId;
};
@ -76,7 +71,6 @@ in
dotnetFixupHook = callPackage ({ }:
makeSetupHook {
name = "dotnet-fixup-hook";
propagatedBuildInputs = [ dotnet-runtime ];
substitutions = {
dotnetRuntime = dotnet-runtime;
runtimeDeps = libraryPath;