简体   繁体   中英

Run C# text template every build

Last year I implemented this solution https://stackoverflow.com/a/19314275/1166898 to automatically update the copyright notice when the project is built, but I found out this year that the template isn't run unless it's changed, and it warns me that it's not trusted before running it.

在此处输入图像描述

How do I

  1. run this file every build without it needing to be changed
  2. trust just this file without automatically trusting every other .tt file

If it's not possible, what's a better way of updating the copyright year automatically?

There's a surprisingly easy way using Property Functions in your.csproj;

<PropertyGroup>
    <Copyright>My Company $([System.DateTime]::Now.Year)</Copyright>
</PropertyGroup>

So long as you haven't set <GenerateAssemblyInfo>false</GenerateAssemblyInfo> , then the usual set of assembly attributes will be generated for you from MSBuild properties. See the documentation for more info.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM