https://github.com/aldaviva/copywriter
© Automatically update copyright years in project sources. Handles .NET SDK-style .csproj files and .NET AssemblyInfo.cs files.
https://github.com/aldaviva/copywriter
copyright csproj
Last synced: 14 days ago
JSON representation
© Automatically update copyright years in project sources. Handles .NET SDK-style .csproj files and .NET AssemblyInfo.cs files.
- Host: GitHub
- URL: https://github.com/aldaviva/copywriter
- Owner: Aldaviva
- License: apache-2.0
- Created: 2024-01-13T08:53:41.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-01-10T11:13:02.000Z (4 months ago)
- Last Synced: 2025-04-10T14:20:02.401Z (18 days ago)
- Topics: copyright, csproj
- Language: C#
- Homepage:
- Size: 68.4 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: License.txt
Awesome Lists containing this project
README
Copywriter
===[](https://github.com/Aldaviva/Copywriter/actions/workflows/dotnet.yml)
Automatically update copyright years in project sources.
- [Quick Start](#quick-start)
- [Behavior](#behavior)
- [Supported files](#supported-files)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Usage](#usage)## Quick Start
```ps1
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](#supported-files) found in the given [parent directory](#parentdirectory), 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 2024 the following copyright string would only update the year 2023, not 1994, 2009, 2010, or 2019.
```diff
- © 1994-2009 Sun, 2010-2019 Oracle, 2019-2023 Apache
+ © 1994-2009 Sun, 2010-2019 Oracle, 2019-2024 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 `` (or the `.Web` variant for ASP.NET Core) can use the `` property.
```xml
© 2023 $(Authors)
```
If the current year is 2024, you can use this program to automatically update the property to
```xml
© 2024 $(Authors)
```### .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 `` set to `false`) can use the `[assembly: AssemblyCopyright]` assembly-level attribute.
```cs
using System.Reflection;[assembly: AssemblyCopyright("© 2023 Ben Hutchison")]
```If the current year is 2024, you can use this program to automatically update the attribute to
```cs
[assembly: AssemblyCopyright("© 2024 Ben Hutchison")]
```## Prerequisites
- [.NET Runtime 8 for Windows x64 or later](https://dotnet.microsoft.com/en-us/download)## Installation
1. Download [`Copywriter.exe`](https://github.com/Aldaviva/Copywriter/releases/latest/download/Copywriter.exe) from the [latest release](https://github.com/Aldaviva/Copywriter/releases/latest).## Usage
### Syntax
```ps1
Copywriter [options]
```### Example
```ps1
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.
```ps1
# 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.```ps1
Copywriter -n
```#### `-d `, `--max-depth `
Recursively search for files in at most `` 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.
```ps1
Copywriter -d 3 "C:\Users\Ben\Documents\Projects"
```#### `-y `, `--year `
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.
```ps1
Copywriter -y 2024
```#### `--exclude-dir `
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.
```ps1
Copywriter --exclude-dir "lib" --exclude-dir "vendor" --exclude-dir "thirdparty"
```#### `--exclude-name `
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.
```ps1
Copywriter --exclude-name "Microsoft"
```#### `--include-name `
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.
```ps1
Copywriter --include-name "Ben Hutchison" --include-name "Benjamin Hutchison"
```