Skip to content

Aldaviva/Copywriter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

© Copywriter

GitHub Actions

Automatically update copyright years in project sources.

Quick Start

Copywriter --max-depth 3 --dry-run
Copywriter --max-depth 3

After showing a preview, this will change all of the copyright years to the current year in supported files in the current working directory and all subdirectories up to 3 levels deep.

Behavior

For each supported file found in the given parent directory, all copyright strings will be searched for four-digit numbers. The last occurrence in each copyright string will be replaced with the new year. This means that ranges and lists should correctly update the latest year only. For example, in 2026 the following copyright string would only update the year 2023, not 1994, 2009, 2010, or 2019.

- © 1994-2009 Sun, 2010-2019 Oracle, 2019-2023 Apache
+ © 1994-2009 Sun, 2010-2019 Oracle, 2019-2026 Apache

The rest of the string will be left unmodified, including names, punctutation, and symbols like ©. This program does not rely on any formats in the copyright string besides a four-digit year appearing somewhere.

Supported files

.NET SDK-style project

.NET projects with the <Project Sdk="Microsoft.NET.Sdk*"> root element and <GenerateAssemblyInfo> not set to false can use the <Copyright> property.

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <Copyright>© 2023 $(Authors)</Copyright>
    </PropertyGroup>
</Project>

If the current year is 2026, you can use this program to automatically update the property to

<Copyright>© 2026 $(Authors)</Copyright>

MSBuild default folder properties

Folders with a Directory.Build.props file can set the <Copyright> property for all .NET projects in the current and all descendant folders.

The syntax is the same as .NET SDK-style projects.

.NET AssemblyInfo file

.NET projects with the AssemblyInfo.cs file (such as .NET Framework projects built with an MSBuild-style project, or any .NET SDK-style project built with <GenerateAssemblyInfo> set to false) can use the [assembly: AssemblyCopyright] assembly-level attribute.

using System.Reflection;

[assembly: AssemblyCopyright("© 2023 Ben Hutchison")]

If the current year is 2026, you can use this program to automatically update the attribute to

[assembly: AssemblyCopyright("© 2026 Ben Hutchison")]

Prerequisites

Installation

  1. Download Copywriter.exe from the latest release.

Usage

Syntax

Copywriter [options] <parentDirectory>

Example

Copywriter --max-depth 3 --include-name 'Ben' --include-name '$(Authors)' ~\Documents\Projects

Options

parentDirectory

The directory in which to search for .csproj and AssemblyInfo.cs files.

Optional. If omitted, it uses the current working directory.

# update files in current working directory
Copywriter

# update files in a specific directory
Copywriter "C:\Users\Ben\Documents\Projects\Copywriter\Copywriter"

-n, --dry-run

Preview the changes that would be made, but don't actually save them.

Copywriter -n

-d <N>, --max-depth <N>

Recursively search for files in at most <N> levels of subdirectories.

Optional. If omitted, defaults to 0, which only searches for files in the current working directory, but not in any of its subdirectories.

Copywriter -d 3 "C:\Users\Ben\Documents\Projects"

-y <Y>, --year <Y>

Set the copyright year to be this custom year, instead of the current year.

Useful if you're preparing a future release on December 31, for example.

Copywriter -y 2027

--exclude-dir <D>

Specify a directory name that should not be searched for files. All subdirectories and files will be excluded if this directory name appears at any level in their path — it's not relative to the parentDirectory, and can't contain multiple path segments like a/b.

You can pass this multiple times to exclude multiple directories.

Copywriter --exclude-dir "lib" --exclude-dir "vendor" --exclude-dir "thirdparty"

--exclude-name <N>

Do not update the copyright text if this string appears within it.

You can pass this multiple times to skip copyright lines that contain any of the excluded strings. Exclusion takes precedence over inclusion.

Copywriter --exclude-name 'Microsoft'

--include-name <N>

Only update the copyright text if this string appears within it.

You can pass this multiple times to skip copyright lines that do not contain any of the included strings. Exclusion takes precedence over inclusion.

Copywriter --include-name 'Ben Hutchison' --include-name 'Benjamin Hutchison' --include-name '$(Authors)'

About

© Automatically update copyright years in project sources. Handles .NET SDK-style .csproj files and .NET AssemblyInfo.cs files.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

Contributors

Languages