Create .NET development environment quickly by running:
$ nix flake init --template github:thomaslaich/dotnet-templateIf you don't have nix installed, run this first:
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Tools used:
- Nix + Flakes
- devenv and direnv for development shell
- just as a task runner; run
justin devshell - csharpier for opinionated code formatting of C#
- treefmt for formatting of all code on the pipeline (C# and nix)
The .NET code is taken from the book: C# 12 and .NET 8 – Modern Cross-Platform Development Fundamentals - Eighth Edition
The template repo can be found here: https://github.com/markjprice/cs12dotnet8/tree/main/code/PracticalApps
This repo merely adds a nix flake that provides a development environment as well as packaged applications that can be run in isolation.
Simply run the following command from the root of the project:
$ nix develop --impureThis will install a .NET SDK in version 9 and all other required dependencies in a completely isolated way (they will not interfere with any system installations of .NET SDK or any other software).
For even better ergonomics, install direnv using your favourite package manager. After that, just cd into the directory
and run direnv allow to enable the automatic shell hook.
When using vscode or emacs, use the corresponding direnv extension:
To restore the entire solution (which creates packages.lock.json files that are also used for packaging):
$ just restoreTo build the entire solution:
$ just buildTo build a single app, e.g., mvc:
$ just build mvcPossible values are:
entity-models(forNorthwind.EntityModels.Sqlite)data-context(forNorthwind.DataContext.Sqlite)web(forNorthwind.Web)webapi(forNorthwind.WebApi)mvc(forNorthwind.Mvc)
To run an application, e.g., mvc:
$ just run mvc