https://github.com/trigger-segfault/TriggersTools.Build
Automated MSBuild targets to add or change information about the assembly.
https://github.com/trigger-segfault/TriggersTools.Build
assembly build-time copyright dotnet msbuild
Last synced: 3 months ago
JSON representation
Automated MSBuild targets to add or change information about the assembly.
- Host: GitHub
- URL: https://github.com/trigger-segfault/TriggersTools.Build
- Owner: trigger-segfault
- License: mit
- Created: 2018-07-16T19:43:09.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-21T20:52:43.000Z (over 6 years ago)
- Last Synced: 2025-06-30T21:47:58.759Z (3 months ago)
- Topics: assembly, build-time, copyright, dotnet, msbuild
- Language: C#
- Size: 111 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: License.md
Awesome Lists containing this project
README
# TriggersTools.Build 
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}`.
[](https://discord.gg/vB7jUbY)
***
# BuildTime 
[](https://www.nuget.org/packages/TriggersTools.Build.BuildTime/)
[](https://www.nuget.org/packages/TriggersTools.Build.BuildTime/)
[](https://github.com/trigger-death/TriggersTools.Build/commit/1815ace69913ee52b43418dea600d84721d111d8)**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](https://stackoverflow.com/a/1600990/7517185), (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()`.
# CopyrightYear 
[](https://www.nuget.org/packages/TriggersTools.Build.CopyrightYear/)
[](https://www.nuget.org/packages/TriggersTools.Build.CopyrightYear/)
[](https://github.com/trigger-death/TriggersTools.Build/commit/1815ace69913ee52b43418dea600d84721d111d8)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`](https://github.com/trigger-death/TriggersTools.Build/blob/master/samples/Framework.Test/Framework.Test.csproj#L17) 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}`.