Skip to content

thomaslaich/dotnet-template

Repository files navigation

.NET nix template for multi-project repo

Create .NET development environment quickly by running:

$ nix flake init --template github:thomaslaich/dotnet-template

If 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 just in devshell
  • csharpier for opinionated code formatting of C#
  • treefmt for formatting of all code on the pipeline (C# and nix)

Note

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.

Develop

Simply run the following command from the root of the project:

$ nix develop --impure

This 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:

Restore

To restore the entire solution (which creates packages.lock.json files that are also used for packaging):

$ just restore

Build

To build the entire solution:

$ just build

To build a single app, e.g., mvc:

$ just build mvc

Possible values are:

  • entity-models (for Northwind.EntityModels.Sqlite)
  • data-context (for Northwind.DataContext.Sqlite)
  • web (for Northwind.Web)
  • webapi (for Northwind.WebApi)
  • mvc (for Northwind.Mvc)

Run an app

To run an application, e.g., mvc:

$ just run mvc

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors