Visual Studio 程序集属性的 2013 运行时文本模板

Visual Studio 2013 runtime text template for assembly properties

我正在尝试(到目前为止未成功)使用运行时文本模板在 AssemblyCopyright 属性 上设置年份。我想这样做是为了使这个过程自动化,这样我们就不必考虑它了(老板希望我们在新的一年每次发布时都更新它)。文件内容如下:

<#@ template language="C#" #>
using System;
using System.Reflection;

[assembly: AssemblyCopyright("Copyright (c) <#=year#> My Company, Inc.")]
<#+
    String year = DateTime.Now.Year.ToString();
#>

我使用了这个文件并注释掉了 AssemblyInfo.cs 中的相应行。编译项目时,程序属性仅显示版权空白。有什么建议吗?

如果您使用的是运行时文本模板(自定义工具=TextTemplatingFilePreprocessor) ,在运行时转换文本的地方,您需要将其更改为仅 文本模板(自定义工具 = TextTemplatingFileGenerator)。