An open API service indexing awesome lists of open source software.

https://github.com/cor/flake-template-dotnet

Reproducibly build a dotnet project with Nix
https://github.com/cor/flake-template-dotnet

Last synced: 8 months ago
JSON representation

Reproducibly build a dotnet project with Nix

Awesome Lists containing this project

README

          

# .NET/Nix Project Template

A template for building .NET applications with Nix (+Refit HTTP client as a nuget dependency example)

## How to reproducibly build and run
```bash
nix build
./result/bin/MyApp

# Or run directly
nix run
```

## Adding New NuGet Dependencies
Follow these steps to add a new NuGet package:

1. **Add package reference** to `MyApp.csproj`:
```xml

```

2. **Update `deps.nix`** with a new entry (use placeholder hash first):
```nix
(fetchNuGet {
pname = "New.Package";
version = "X.Y.Z";
sha256 = lib.fakeHash; # Temporary placeholder
})
```

3. **Get real SHA256 hash** by building and extracting the sha-256 from the output:
```bash
nix build -L
# observe what the sha-256 should be
```

4. **Replace** `lib.fakeHash` with the actual hash output by the nix build error

## Development Environment
```bash
# Enter development shell with all tools
nix develop

# Normal .NET commands work inside the shell:
dotnet build
dotnet run
```

### Editor Setup
The dev shell includes:
- Omnisharp (C# language server)
- .NET SDK 8.0
- NuGet dependency tools

Ensure your editor uses the `./.nuget-packages` directory for packages.