mikefourie-zz / MSBuildExtensionPack

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Enhancement for Shared Assembly Info file

fiki2fiki opened this issue · comments

Hi Mike,

Hope you're doing good.

Requirement: We need to update AssemblyInformationalVersion which we have placed in a SharedAssemblyInfo.cs file with other common attributes like company etc. The shared file then added to the projects as link in properties as sibling to AssemblyInfo.cs.

Issue faced: Whenever we tried to run task (MSBuild.ExtensionPack.Framework.AssemblyInfo) from MSBuild target file (shown below) we got an error that AssemblyVersion is not present. This issue was obvious as AssemblyVersion and AssemblyFileVersion attributes are present in AssemblyInfo.cs file only, which is associated per project. So, we did the following (but, even that didn't fulfilled our motive):

<ItemGroup>
      <AssemblyInfoFiles Include="$(MSBuildProjectDirectory)\Properties\*.cs" />
      <SharedAssemblyInfoFile Include="$(TF_BUILD_SOURCESDIRECTORY)\$(SharedAssemblyInfoPath)\SharedAssemblyInfo.cs"/>
    </ItemGroup>

<MSBuild.ExtensionPack.Framework.AssemblyInfo
       AssemblyInfoFiles="@(AssemblyInfoFiles)"
        AssemblyFileBuildNumber="$(SharedBuildVersionNumber)"
       AssemblyFileBuildNumberType="NoIncrement"
        AssemblyFileRevision="$(AssemblyFileRevisionNumber)"
       AssemblyFileRevisionType="NoIncrement"
      />

      <MSBuild.ExtensionPack.Framework.AssemblyInfo
      AssemblyInfoFiles="@(SharedAssemblyInfoFile)"
        UpdateAssemblyInformationalVersion="true"
       AssemblyInformationalVersion="$(SharedAssemblyInformationalVersionFinal)"
      />

Solution: To accomplish our goal we made few changes to the AssemblyInfo class' Execute method. We have attached the same in zip. In this we have added a flag which is being set when we have the SharedAssemblyInfo.cs file as input. In that case it updates AssemblyInformationalVersion only and skips other checks.

AssemblyInfo.zip

Question:

  • Is the change is safe to implement and is it appropriate?
  • Can we contribute this to your project after some clean up, if required?

Thanks

Hi, just set SkipVersioning="true" to avoid version operations when working with that file