简体   繁体   中英

How can I change Assembly Version,Assembly File Version by compliling code using System.CodeDom.CodeCompileUnit

Hi I dnt have Assembly Info file I have a code generator that copile the code using System.CodeDom.CodeCompileUnit, but always on compiling code Assembly File version and Assembly version remain 0.0.0.0

Any answer will really appreciate.

Thanks

CodeCompileUnit unit = new CodeCompileUnit();

// ...

CodeTypeReference attr = new CodeTypeReference(typeof(AssemblyVersionAttribute));

CodeAttributeDeclaration decl = new CodeAttributeDeclaration(attr, new CodeAttributeArgument(new CodePrimitiveExpression("1.0.2.42")));

unit.AssemblyCustomAttributes.Add(decl);

should work with AssemblyFileVersion as well. see here

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