A collection of .NET libraries for automated assignment and modification of assembly info, either through MSBuild property or assembly info file. Both are designed to begin working immediately after being installed as a NuGet package. Although CopyrightYear
requires that the current year in the copyright information be replaced with {YEAR}
.
Version 2: Embeds a resource file that contains the ISO 8601 timestamp for when the project build was started. This new method means the parent assembly is no longer forcefully tied to the TriggersTools.Build.BuildTime
assembly the moment it is loaded. Now the TriggersTools.Build.BuildTime
assembly can be loaded at a later time, or not at all.
Version 1: Automatically assigns an AssemblyBuildTimeAttribute
to the assembly during the beginning of the build.
Build time can be aquired through extension methods such as Assembly.GetBuildTime()
with AssemblyBuildTimeExtensions
in the namespace TriggersTools.Build
. Unlike relying on the linker time, (which already no longer works in .NET Core 1.1 and later), this method guarantees that the build time will be present as long as it was compiled with MSBuild.
You can check if an assembly has an AssemblyBuildTimeAttribute
by calling the extension method Assembly.HasBuildTime()
.
Replaces all instances of {YEAR}
in copyrights with the current year. Works with the MSBuild $(Copyright)
property and the AssemblyCopyrightAttribute
.
Assign the $(CopyrightYearAssemblyInfo)
property in your project file as your input assembly info file if you're using one different from Properties\AssemblyInfo.cs
. Assembly files are local to $(ProjectDir)
unless rooted.
See Framework.Test.csproj
for an example of assigning the $(CopyrightYearAssemblyInfo)
property.
This does not work for NuGet packages generated by Sdk projects. Use $([System.DateTime]::Now.Year)
(or UtcNow
) for these projects instead of {YEAR}
.