Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuild Task for setting custom attribute in AssemblyInfo.cs

Is there a MSBuild task for setting custom attribute in AssemblyInfo.cs? I found AssemblyInfo task but it seems that it cannot set custom attributes, only predefined ones. I'd like to set 3 custom properties I have added into this file.

Any suggestion how to solve this?

like image 778
Vajda Avatar asked Jun 11 '12 12:06

Vajda


1 Answers

WriteCodeFragment task can help:

<Target Name="BeforeBuild">
    <ItemGroup>
     <AssemblyAttributes Include="AssemblyTitle">
        <_Parameter1>My Assembly</_Parameter1>
     </AssemblyAttributes>
     <AssemblyAttributes Include="AssemblyDescription">
        <_Parameter1>My Assembly</_Parameter1>
     </AssemblyAttributes>  
     <AssemblyAttributes Include="AssemblyCompany">
        <_Parameter1>My Company</_Parameter1>
     </AssemblyAttributes>
     <AssemblyAttributes Include="AssemblyProduct">
        <_Parameter1>My Product</_Parameter1>
     </AssemblyAttributes>
     <AssemblyAttributes Include="AssemblyCopyright">
        <_Parameter1>Copyright © 2012</_Parameter1>
     </AssemblyAttributes>
     <AssemblyAttributes Include="AssemblyCulture">
        <_Parameter1></_Parameter1>
     </AssemblyAttributes>       
     <AssemblyAttributes Include="AssemblyVersion">
        <_Parameter1>1.0.0.0</_Parameter1>
     </AssemblyAttributes>   
     <AssemblyAttributes Include="AssemblyFileVersion">
        <_Parameter1>1.0.0.0</_Parameter1>
     </AssemblyAttributes>
     <AssemblyAttributes Include="System.Runtime.InteropServices.Guid">
        <_Parameter1>e7a979b2-0a4f-483a-ba60-124e7ef3a931</_Parameter1>
     </AssemblyAttributes>
    </ItemGroup>
  <WriteCodeFragment Language="C#" OutputFile="Properties/AssemblyInfo.cs" AssemblyAttributes="@(AssemblyAttributes)" />
</Target>
like image 82
KMoraz Avatar answered Oct 03 '22 07:10

KMoraz