1

I'm trying to add custom properties to CodeDOM output, such as file version, author, etc. I'm unsure how.

Meme Machine
  • 949
  • 3
  • 14
  • 28

1 Answers1

1

For the file version, you have to use AssemblyFileVersion attribute. See the example.

CodeCompileUnit unit = CreateMyUnit();
var attribute = new CodeAttributeDeclaration(
    new CodeTypeReference(typeof(AssemblyFileVersionAttribute)));
attribute.Arguments.Add(
    new CodeAttributeArgument(
        new CodePrimitiveExpression("1.1.1.1")));
unit.AssemblyCustomAttributes.Add(attribute);

As for the author, you may do the similar thing. See the MSDN assembly attribute.

EDIT:

You need add the references.

using System.CodeDom;
using System.CodeDom.Compiler;
Community
  • 1
  • 1
Hui Zhao
  • 655
  • 1
  • 10
  • 20
  • You have to add necessary references.This is because there is no such attribute existing. Check the MSDN link I gave to you. Please use other attribute such as copyright etc. – Hui Zhao Mar 23 '15 at 01:26
  • You have to do two things. A: show your code. B: follow the example on [MSDN](https://msdn.microsoft.com/en-us/library/ms404245%28v=vs.110%29.aspx). – Hui Zhao Mar 23 '15 at 01:56
  • Try to remove the line `[assembly: AssemblyCompanyAttribute("Test")]`. I don't see MSDN example having such a declarative code. – Hui Zhao Mar 23 '15 at 02:07
  • It changed nothing at all. Now I'm back where I started. – Meme Machine Mar 23 '15 at 20:41