Search code examples
nantassemblyinfo

Adding a comment to the file generated by an asminfo NAnt task


I am using the asminfo task in NAnt but would like to be able to include an explanatory comment in the generated file (to tell the uninitiated that the file was generated by NAnt, and what its purpose is).

Is this possible?


Solution

  • I'm not aware of any NAnt function to achieve this directly.

    What you could do is this: Generate AssemblyInfo file, load its content to a property, overwrite the file with your header, and append the original content.

    <asminfo output="${assemblyinfo.path}" language="CSharp">
      <!-- ... -->
    </asminfo>
    <loadfile
      file="${assemblyinfo.path}"
      property="assemblyinfo.content" />
    <echo
      file="${assemblyinfo.path}"
      append="false">
      <![CDATA[//------------------------------------------------------------------------------
    // <copyright file="AssemblyInfo.cs" company="ACME INC.">
    //   Copyright (c) ACME INC.
    // </copyright>
    // <summary>
    //   The assembly info.
    // </summary>
    //------------------------------------------------------------------------------
    
    ]]>
    </echo>
    <echo
      file="${assemblyinfo.path}"
      message="${assemblyinfo.content}"
      append="true" />