Usage:
C:\> StampCopyright.exe copyright.txt src\*.csproj [/svn=Path\to\svn.exe] [/nologo] [/wait]
StampCopyright takes the first argument and reads the copyright notice from it. It then searches each subsequent argument recursively for project files. For every project it finds it then walks the non-generated source files (*.cs) included and inserts the copyright notice.
Options:
- copyright.txt the first parameter is always the copyright prefix to be inserted into the sources files
- src\*.csproj all subsequent parameters that do not begin with a switch (/ or -) will be treated as a recursive file search pattern for projects
- /svn=Path\to\svn.exe when provided, the program will obtain the first-seen year from subversion, see Copyright Text Handling below
- /nologo hides the startup message.
- /wait after processing wait for user input before exiting the process.
Copyright Text Handling
Usually the copyright notice is encased in a #region statement. Whether this is true or not the first text line must always contain the word "Copyright" and the last non-empty line can't contain some special characters as it is injected into a regular expression. Occurrences of the words "YEAR" or "yyyy" will be replaced with the current year. Moreover, if the current copyright on the source file already exists and contains a year less than the current year, these strings will be replace with the appropriate year range, i.e. "2005-2012". The following example is used in this library for copyright insertion:
#region Copyright yyyy by Roger Knapp, Licensed under the Apache License, Version 2.0 /* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #endregion