diff options
author | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2021-12-14 12:01:17 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-14 12:01:17 +0000 |
commit | 0242879f3fa01bdda5b7e204f963b8e6c258ad54 (patch) | |
tree | f4c5e2dfd274ea7c490c220a77d8a422e961b6f1 /doc/languages-frameworks | |
parent | 4ee2a8c8058e1c9d2317345d8630c45703ff5ae8 (diff) | |
parent | d995f2abb98b92b26cc4b8044e3a3251a067757b (diff) |
Merge master into staging-next
Diffstat (limited to 'doc/languages-frameworks')
-rw-r--r-- | doc/languages-frameworks/dotnet.section.md | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/doc/languages-frameworks/dotnet.section.md b/doc/languages-frameworks/dotnet.section.md index f3d9fb8757349..94d97a970dbb1 100644 --- a/doc/languages-frameworks/dotnet.section.md +++ b/doc/languages-frameworks/dotnet.section.md @@ -73,6 +73,17 @@ To package Dotnet applications, you can use `buildDotnetModule`. This has simila * `projectFile` has to be used for specifying the dotnet project file relative to the source root. These usually have `.sln` or `.csproj` file extensions. This can be an array of multiple projects as well. * `nugetDeps` has to be used to specify the NuGet dependency file. Unfortunately, these cannot be deterministically fetched without a lockfile. This file should be generated using `nuget-to-nix` tool, which is available in nixpkgs. +* `packNupkg` is used to pack project as a `nupkg`, and installs it to `$out/share`. If set to `true`, the derivation can be used as a dependency for another dotnet project by adding it to `projectReferences`. +* `projectReferences` can be used to resolve `ProjectReference` project items. Referenced projects can be packed with `buildDotnetModule` by setting the `packNupkg = true` attribute and passing a list of derivations to `projectReferences`. Since we are sharing referenced projects as NuGets they must be added to csproj/fsproj files as `PackageReference` as well. + For example, your project has a local dependency: + ```xml + <ProjectReference Include="../foo/bar.fsproj" /> + ``` + To enable discovery through `projectReferences` you would need to add: + ```xml + <ProjectReference Include="../foo/bar.fsproj" /> + <PackageReference Include="bar" Version="*" Condition=" '$(ContinuousIntegrationBuild)'=='true' "/> + ``` * `executables` is used to specify which executables get wrapped to `$out/bin`, relative to `$out/lib/$pname`. If this is unset, all executables generated will get installed. If you do not want to install any, set this to `[]`. * `runtimeDeps` is used to wrap libraries into `LD_LIBRARY_PATH`. This is how dotnet usually handles runtime dependencies. * `buildType` is used to change the type of build. Possible values are `Release`, `Debug`, etc. By default, this is set to `Release`. @@ -83,15 +94,18 @@ To package Dotnet applications, you can use `buildDotnetModule`. This has simila * `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`. -* `dotnetTestFlags` can be used to pass flags to `dotnet test`. +* `dotnetTestFlags` can be used to pass flags to `dotnet test`. Used only if `doCheck` is set to `true`. * `dotnetInstallFlags` can be used to pass flags to `dotnet install`. +* `dotnetPackFlags` can be used to pass flags to `dotnet pack`. Used only if `packNupkg` is set to `true`. * `dotnetFlags` can be used to pass flags to all of the above phases. Here is an example `default.nix`, using some of the previously discussed arguments: ```nix { lib, buildDotnetModule, dotnetCorePackages, ffmpeg }: -buildDotnetModule rec { +let + referencedProject = import ../../bar { ... }; +in buildDotnetModule rec { pname = "someDotnetApplication"; version = "0.1"; @@ -99,6 +113,7 @@ buildDotnetModule rec { projectFile = "src/project.sln"; nugetDeps = ./deps.nix; # File generated with `nuget-to-nix path/to/src > deps.nix`. + projectReferences = [ referencedProject ]; # `referencedProject` must contain `nupkg` in the folder structure. dotnet-sdk = dotnetCorePackages.sdk_3_1; dotnet-runtime = dotnetCorePackages.net_5_0; @@ -107,6 +122,8 @@ buildDotnetModule rec { executables = [ "foo" ]; # This wraps "$out/lib/$pname/foo" to `$out/bin/foo`. executables = []; # Don't install any executables. + packNupkg = true; # This packs the project as "foo-0.1.nupkg" at `$out/share`. + runtimeDeps = [ ffmpeg ]; # This will wrap ffmpeg's library path into `LD_LIBRARY_PATH`. } ``` |