DotNET: Difference between revisions

Lostmsu (talk | contribs)
No edit summary
YoshiRulz (talk | contribs)
Bring example more in line with Nixpkgs manual re: NuGet deps; don't suggest copying hash from failed build log
Line 18: Line 18:
     repo = pname;
     repo = pname;
     rev = "v${version}";
     rev = "v${version}";
     sha256 = ""; # can be figured out from the first build attempt
     hash = ""; # use e.g. `nix-prefetch-git`
   };
   };


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 = ./nuget-deps.nix; # only if there are NuGet dependencies, real file will be genned later
   nugetDeps = ./deps.nix; # to generate, set to `""`, then `nix-build -A fetch-deps && ./result`


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


To generate <code>nuget-deps.nix</code> file you can run
If the <code>fetch-deps</code> script isn't working for whatever reason, you can manually run <code>nuget-to-nix</code>:
 
<syntaxhighlight lang="sh">
<code>dotnet restore --packages=packageDir SomeProject.csproj && nuget-to-nix packageDir >nuget-deps.nix; rm -rf packageDir</code>
dotnet restore --packages=packageDir ./SomeProject.csproj
nuget-to-nix packageDir >deps.nix
rm -r packageDir
</syntaxhighlight>


After that the package will build normally. Remember to re-run nuget-to-nix every time the package is updated.
Remember to build and run the <code>fetch-deps</code> script after NuGet packages are updated, or building the derivation will fail.


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