Skip to content

Instantly share code, notes, and snippets.

@davidfowl
Last active December 26, 2024 06:41
Show Gist options
  • Save davidfowl/ed7564297c61fe9ab814 to your computer and use it in GitHub Desktop.
Save davidfowl/ed7564297c61fe9ab814 to your computer and use it in GitHub Desktop.
.NET project structure
$/
  artifacts/
  build/
  docs/
  lib/
  packages/
  samples/
  src/
  tests/
  .editorconfig
  .gitignore
  .gitattributes
  build.cmd
  build.sh
  LICENSE
  NuGet.Config
  README.md
  {solution}.sln
  • src - Main projects (the product code)
  • tests - Test projects
  • docs - Documentation stuff, markdown files, help files etc.
  • samples (optional) - Sample projects
  • lib - Things that can NEVER exist in a nuget package
  • artifacts - Build outputs go here. Doing a build.cmd/build.sh generates artifacts here (nupkgs, dlls, pdbs, etc.)
  • packages - NuGet packages
  • build - Build customizations (custom msbuild files/psake/fake/albacore/etc) scripts
  • build.cmd - Bootstrap the build for windows
  • build.sh - Bootstrap the build for *nix
  • global.json - ASP.NET vNext only

.gitignore

[Oo]bj/
[Bb]in/
.nuget/
_ReSharper.*
packages/
artifacts/
*.user
*.suo
*.userprefs
*DS_Store
*.sln.ide

There's probably more things that go in the ignore file.

  • Update: Added docs folder
  • Added README.md and LICENSE - Critical if you're OSS, if not ignore it
  • Renamed test to tests
  • Added lib for things that CANNOT exist in nuget packages
  • Removed NuGet.config for people using packet :)
  • Added global.json for ASP.NET vnext
  • Added .editorconfig file in the root (x-plat IDE settings)
  • Added NuGet.config back because people were confused about it missing
@TechWatching
Copy link

If your git repository also contains the frontend that consumes the dotnet API, where would you put the front code? The application code in /src and the tests code in /tests ?

If UI and backend are worked on by the same team/organisation, they are the same app, and they should be versioned together (i.e. in the same repo) and deployed together.

I agree, I was just wondering what it means for the folder organization.

@mcintyre321
Copy link

mcintyre321 commented Nov 7, 2022 via email

@fvilches17
Copy link

thought I'd share,

this is the structure I follow for some projects. you can imagine that at root, besides the .azuredevops folder, there's src, test etc. folders

the name .azuredevops was chosen because back in Azure DevOps when you place a pull_request_template.md file in a folder with set name, then the repo's PR descriptions use the content of that file, pretty much used like a template for PR descriptions

however, the name can be anything of course. e.g. something generic like .devops

folder structure

@peteraritchie
Copy link

This thread makes me think there are several intents within the discussion. Is @davidfowl 's intent to outline a dotnet project for a monorepo, for deployment to custom infrastructure, for delivery of a package, etc.?

@agilenut
Copy link

This thread makes me think there are several intents within the discussion. Is @davidfowl 's intent to outline a dotnet project for a monorepo, for deployment to custom infrastructure, for delivery of a package, etc.?

My 2 cents:

I follow this structure when I'm not building a monorepo.

When I do build a monorepo, I wrap this structure in another set of folders at the root of the repository (one for each service, library, or app). But I might keep a few things like shared build pipelines, docs, and editorconfig in the root.

@tonidy
Copy link

tonidy commented Jun 4, 2023

@sharpninja @tiny-dancer I've created https://github.com/dotnet-template/project-layout, feel free to fork it and maybe contribute to it.

@aspeckt-112
Copy link

Could someone please explain to me the difference between putting nupkgs in the artefacts directory vs the packages directory?

@Layoric
Copy link

Layoric commented Jan 26, 2024

My understanding is the Artefacts is the output of your project, much could include NuGet packages, packages directory contains your projects dependencies.

@aspeckt-112
Copy link

Ahhh OK. For when a packages.config is being used. Not applicable to me and I think I was tunnel visioning past it.

Thanks, @Layoric

@oxygen
Copy link

oxygen commented Apr 12, 2024

@D3MaxT
Never distribute [the same] private cert to multiple distinct clients, even if you do it securely - you might as well drop encryption altogether.
For self signed certificates just generate them on the client machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment