• Stars
    star
    114
  • Rank 308,031 (Top 7 %)
  • Language
    PowerShell
  • License
    MIT License
  • Created over 5 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A template for a NuGet package with tests, stylecop, fxcop, versioning, and Azure Pipelines build ready to go.

Your Library

An awesome template for your awesome library

NuGet package

Azure Pipelines status GitHub Actions status codecov

Features

  • Follow the best and simplest patterns of build, pack and test with dotnet CLI.
  • Init script that installs prerequisites and auth helpers, supporting both non-elevation and elevation modes.
  • Static analyzers: default Code Analysis and StyleCop
  • Read-only source tree (builds to top-level bin/obj folders)
  • Auto-versioning (via Nerdbank.GitVersioning)
  • Builds with a "pinned" .NET Core SDK to ensure reproducible builds across machines and across time.
  • Automatically pack the library and publish it as an artifact, and even push it to some NuGet feed for consumption.
  • Testing
    • Testing on .NET Framework, multiple .NET Core versions
    • Testing on Windows, Linux and OSX
    • Tests that crash or hang in Azure Pipelines automatically collect dumps and publish as a pipeline artifact for later investigation.
  • Cloud build support
    • YAML based build for long-term serviceability, and PR review opportunities for any changes.
    • Azure Pipelines and GitHub Action support
    • Emphasis on PowerShell scripts over reliance on tasks for a more locally reproducible build.
    • Code coverage published to Azure Pipelines
    • Code coverage published to codecov.io so GitHub PRs get code coverage results added as a PR comment

Consumption

Once you've expanded this template for your own use, you should run the Expand-Template.ps1 script to customize the template for your own project.

Further customize your repo by:

  1. Verify the license is suitable for your goal as it appears in the LICENSE and stylecop.json files and the Directory.Build.props file's PackageLicenseExpression property.
  2. Reset or replace the badges at the top of this file.

Maintaining your repo based on this template

The best way to keep your repo in sync with this template's evolving features and best practices is to periodically merge the template into your repo:

git checkout main          # your default branch
git pull                   # make sure you're at tip
git fetch libtemplate      # fetch latest Library.Template
git merge libtemplate/main

There will frequently be merge conflicts to work out, but they will be easier to resolve than running the Apply-Template.ps1 script every time, which simply blows away all your local changes with the latest from the template.

If you do not already have Library.Template history in your repo or have never completed a merge before, the above steps may produce errors. To get it working the first time, follow these steps:

git remote add libtemplate https://github.com/AArnott/Library.Template.git
git fetch libtemplate

If the git merge step described earlier still fails for you, you may need to artificially create your first merge. First, you must have a local clone of Library.Template on your box:

git clone https://github.com/AArnott/Library.Template.git

Make sure you have either main checked out in that clone, as appropriate to match. Use git rev-parse HEAD within the Library.Template repo and record the resulting commit as we'll use it later.

Run the Apply-Template.ps1 script, passing in the path to your own Library.Template-based repo. This will blow away most customizations you may have made to your repo's build authoring. You should carefully review all changes to your repo, staging those changes that you want to keep and reverting those that remove customizations you made.

Now it's time to commit your changes. We do this in a very low-level way in order to have git record this as a merge commit even though it didn't start as a merge. By doing this, git will allow future merges from libtemplate/main and only new changes will be brought down, which will be much easier than the Apply-Template.ps1 script you just ran. We create the merge commit with these commands:

  1. Be sure to have staged or reverted all the changes in your repo.
  2. Run git write-tree within your repo. This will print out a git tree hash.
  3. Run git commit-tree -p HEAD -p A B -m "Merged latest Library.Template", where A is the output from git rev-parse HEAD that you recorded earlier, and B is the output from your prior git write-tree command.
  4. Run git merge X where X is the output of the git commit-tree command.

IMPORTANT: If using a pull request to get your changes into your repo, you must merge your PR. If you squash your PR, history will be lost and you will have to repeatedly resolve the same merge conflicts at the next Library.Template update.

CAUTION: when merging this for the first time, a github-hosted repo may close issues in your repo with the same number as issues that this repo closed in git commit messages. Verify after completing your PR by visiting your github closed issues, sorted by recently updated, and reactivate any that were inadvertently closed by this merge. This shouldn't be a recurring issue because going forward, we will avoid referencing github issues with simple #123 syntax in this repo's history.

Congratulations. You're all done. Next time you want to sync to latest from Library.Template, you can the simple git merge steps given at the start of this section.

More Repositories

1

CodeGeneration.Roslyn

Assists in performing Roslyn-based code generation during a build.
C#
408
star
2

IronPigeon

IronPigeon is a decentralized communication protocol that provides high confidentiality and authenticity for the messages.
C#
261
star
3

PCLCrypto

Platform crypto for portable libraries
C#
227
star
4

ImmutableObjectGraph

Code generation for immutable types
C#
160
star
5

Validation

Method input validation and runtime checks that report errors or throw exceptions when failures are detected.
C#
127
star
6

Xunit.Combinatorial

Adds combinatorial and pairwise testing capability to Xunit tests
C#
123
star
7

Xunit.SkippableFact

Adds Xunit dynamic skipping of facts and theories.
PowerShell
121
star
8

Xunit.StaFact

Run your xunit-based tests on an STA thread with the WPF Dispatcher, a WinForms SynchronizationContext, or even a cross-platform generic UI thread emulation with a SynchronizationContext that keeps code running on a "main thread" for that test.
C#
80
star
9

MoneyMan

A financial money management library and applications that utilize it.
C#
39
star
10

SPSS.NET

A .NET library for read/writing SPSS Data (.sav) files. This wraps the functionality exposed by the spssio32.dll native library that comes with SPSS.
C#
31
star
11

StreamJsonRpc.Sample

Sample use of StreamJsonRpc that demonstrate separate client/server processes over named pipes.
C#
28
star
12

Nerdbank.MSBuildExtension

Package to make writing MSBuild extensions easier that work both with MSBuild Core and MSBuild (Full).
C#
23
star
13

PPApiForDotNet

Write PPAPI extensions for Chromium in your favorite .NET language.
C++
20
star
14

CSharpIsNull

C# null test syntax analyzers to guard against bugs in testing null against a struct.
PowerShell
14
star
15

AssemblyRefScanner

Scans a given directory tree for interesting assembly references
C#
14
star
16

Nerdbank.Algorithms

A collection of algorithms I've implemented and found generally useful
C#
13
star
17

Pfx2Snk

Converts PFX files to SNK files.
Visual Basic
12
star
18

DotNetRepoTools

A CLI tool with commands to help maintain .NET codebases
C#
11
star
19

PInvoke.exp

C#
10
star
20

Bitcoin.NET

A .NET Bitcoin library
C#
9
star
21

nerdbank.stylecop.rules

Custom rules for StyleCop
C#
9
star
22

GuidGen

A GuidGen tool similar to the one that ships with VS, but less than a decade old.
PowerShell
8
star
23

ReadOnlySourceTree

A NuGet package that makes your project build to top-level bin and obj directories.
C#
7
star
24

PlugInServer

A network server that can do whatever the live-dropin modules tell it to (HTTP, telnet, ASP.NET, PHP, etc.)
C#
6
star
25

MessagePackDualVersions

Demonstrates how an application can run multiple incompatible versions of a library at once (MessagePack).
C#
5
star
26

Node.js.redist

Builds packages that contain Node.js that can be used to redistribute across platforms
PowerShell
5
star
27

OpenIDForSharepoint

A MembershipProvider for Sharepoint that enabled OpenID logins (forked from CodePlex). BEWARE: Read the README.txt file.
C#
5
star
28

csharplibrarystarterkit

A starting point for C# library development, including logging, tests and build system
JavaScript
4
star
29

YouTubeDownloader

A CLI tool for downloading YouTube videos.
C#
4
star
30

win-buildagent

Docker image build for a windows build agent
Dockerfile
4
star
31

pr-autocomplete-app

A GitHub App that adds auto-complete functionality to pull requests similar to that found in Azure Repos.
TypeScript
4
star
32

dotnetxri

A C# port of the OpenXri4j library
C#
4
star
33

JavascriptCssPackerTargets

An MSBuild-based .targets file and task assembly for minifying js and css embedded resources
C#
4
star
34

cloudbuild-task

Contracts and adapter NPM packages for various cloud build services
TypeScript
4
star
35

PCLCommandBase

A common base class for ICommand implementations, and a BindableBase class for your viewmodels
PowerShell
3
star
36

Nerdbank.Qif

C#
3
star
37

HttpClientEcho

Enables automated tests with HTTP calls to avoid incurring the cost and instability of network traffic by recording a "live" test run and replaying it for subsequent test runs.
C#
3
star
38

dasblog

A private dasblog playground for assembling patches for the official version on CodePlex
C#
3
star
39

StreamingMsgPackSample

A sample of streaming MessagePack from a child process to a parent process
C#
3
star
40

VSIXProjectWithPackageReferences

A sample of a VSIX project that uses PackageReference instead of packages.config. The grass is greener here.
C#
2
star
41

ClueBuddy

A program to run while playing the popular game Clue to help you deduce all the possible clues possible and win
C#
2
star
42

AsyncAndThreadingDemo.Wpf

A simple WPF that shows up async/threading patterns, including JTF
C#
2
star
43

atom2blogger

A blog-to-blog conversion utility for transferring a blog published by Atom feed to Blogger.
C#
2
star
44

Clue

A Clue board game partner to help you deduce clues. Written in Ruby.
Ruby
1
star
45

IdentitySelector

FireFox plug-in for Information Cards support
C++
1
star
46

GoogleAppEngineHiPy

The Hello World app for Google App Engine in Python
Python
1
star
47

setup-dotnet-test

C#
1
star
48

StaticPGO_Example

How to collect a static (not the dynamic one) PGO and re-use it during "dotnet publish"
C#
1
star
49

googauth

Sample .NET web site that uses Google authentication
C#
1
star
50

EnlistmentInfo

A NuGet package that imports EnlistmentInfo .props and .targets from a parent directory.
1
star
51

VSPerfDemo

A repo demonstrating a VS Package that evolves from causing UI delays to a responsive extension.
C#
1
star
52

Nerdbank.Cryptocurrencies

.NET libraries for processing Zcash and other cryptocurrencies.
C#
1
star
53

MyNHibernateContrib

C#
1
star
54

Nerdbank.Algorithms.rs

Rust
1
star
55

pr-autocomplete-scratch

Just a scratch pad for testing PR auto-complete GitHub Actions
PowerShell
1
star