DotNET: Difference between revisions

Lostmsu (talk | contribs)
m Undo revision 13402 by Lostmsu (talk)
Tag: Undo
Lostmsu (talk | contribs)
nuget-to-nix is much more straightforward to use than fetch-deps script
Line 24: Line 24:
   dotnet-sdk = dotnetCorePackages.sdk_8_0;
   dotnet-sdk = dotnetCorePackages.sdk_8_0;
   dotnet-runtime = dotnetCorePackages.runtime_8_0;
   dotnet-runtime = dotnetCorePackages.runtime_8_0;
   nugetDeps = null; # only if there are NuGet dependencies, real file will be genned later
   nugetDeps = ./nuget-deps.nix; # only if there are NuGet dependencies, real file will be genned later


   meta = with lib; {
   meta = with lib; {
Line 35: Line 35:
</syntaxhighlight>
</syntaxhighlight>


Note that the above package will not build the first time. After adding the above definition to `all-packages.nix`, you
To generate <code>nuget-deps.nix</code> file you can run
can run the package-specific `fetch-deps` script, which will generate a file containing all the nuget dependencies of the
package. Build the script with <code>nix-build -A some-package.fetch-deps</code>, might need to run <code>./result deps.nix</code>, copy that generated file (the location will be printed by the script) and set the <code>nugetDeps</code> attribute in <code>buildDotnetModule</code> to point to that generated file (ie. <code>nugetDeps = ./deps.nix</code>).


After that the package will build normally. Remember to re-run <code>fetch-deps</code> every time the package is updated.
<code>dotnet restore --packages=packageDir SomeProject.csproj && nuget-to-nix packageDir >nuget-deps.nix; rm -rf packageDir</code>
 
After that the package will build normally. Remember to re-run nuget-to-nix every time the package is updated.


== Building non-.NET Core packages ==
== Building non-.NET Core packages ==