How to specify the solution file location for versioning assembly info files in MSBUILD

302 views Asked by At

I have been fiddling with this for a day but no luck. The assembly versioning with MSBUILD used to work before, but recently we have moved the solution files to a separate folder within the Root of the project, and since then the versioning has not been working.

Below is the project structure

Code folder

-> ProjectA folder

-> ProjectB folder

-> ProjectC folder

-> Solutions folder

*Previously the Solutions (.sln) files were under the Code folder.

When we run the MSBuild I get the below warning.

No assembly information files were provided

Below is a cut down version of the build log.

Delete Workspace

00:00 Delete Sources Directory

00:00 Create Workspace

01:14 Get Workspace

00:00 Versioning Assemblies

00:00 AssemblyVersion and AssemblyFileVersion Assembly Version Processing: Using version number patterns included in build definition

00:00 Set all Assembly Property Values (b) Versioning assemblies with the following patterns: AssemblyVersion(1.0.0.0) and AssemblyFileVersion(yyyy.mm.dd.b) No assembly information files were provided

Below is the MSBuild Task that produces the above log.

  <local:VersionAssemblyInfoFiles 
    AssemblyFileVersionPattern="[AssemblyFileVersionPattern]" 
    AssemblyInfoFilePattern=" AssemblyInfoFilePattern]" 
    AssemblyVersionPattern="[AssemblyVersionPattern]" 
    BuildDirectory="[BuildDirectory]" BuildNumberPrefix=" 
   [BuildNumberPrefix]" BuildSettings="[BuildSettings]" 
    DisplayName="Versioning Assemblies" 
    DoCheckinAssemblyInfoFiles="[DoCheckinAssemblyInfoFiles]" 
    ForceCreateVersion="[ForceCreateVersion]" 
    sap:VirtualizedContainerService.HintSize="200,22" 
    mva:VisualBasic.Settings="Assembly references and imported namespaces 
   serialized as XML namespaces" UseVersionSeedFile="[UseVersionSeedFile]" 
   VersionSeedFilePath="[VersionSeedFilePath]" Workspace="[Workspace]" 
   xmlns:local="clr-namespace:TfsBuild.Versioning.Activities;
   assembly=TfsBuild.Versioning.Activities">

      <sap:WorkflowViewStateService.ViewState>
        <scg:Dictionary x:TypeArguments="x:String, x:Object">
          <x:Boolean x:Key="ShouldCollapseAll">False</x:Boolean>
          <x:Boolean x:Key="ShouldExpandAll">True</x:Boolean>
        </scg:Dictionary>
      </sap:WorkflowViewStateService.ViewState>
 </local:VersionAssemblyInfoFiles>

I also looked at the solution suggested here but have no luck. Can someone please point me to the right direction? I 'm no expert in MSBuild.

Thanks in advance.

1

There are 1 answers

0
Spock On BEST ANSWER

I ended up doing the following workaround. We do not have an option to move all solutions to the Root level of the project.

a. Create a new solution i.e SomeApp.Lib.Versioning.sln This solution would live under the root folder and it is only used for versioning the rest of the projects.

b. The project (.csproj) for the SomeApp.Lib.Versioning.sln would live in the same level as the rest of the projects.

So the new structure is

Code folder

-> ProjectA folder

-> ProjectB folder

-> ProjectC folder

-> Solutions folder

-> SomeApp.Lib.Versioning.sln

-> SomeApp.Lib.Versioning folder

c. Now I reference the SomeApp.Lib.Versioning.proj from one of the solutions within Solutions folder. This means SomeApp.Lib.Versioning.proj has two solutions attached to hit.

d. The project that display the build version would use the type i.e Class file from the SomeApp.Lib.Versioning.proj

As per the standard build versioning SomeApp.Lib.Versioning.proj would have the correct build version(SomeApp.Lib.Versioning.sln is in the Root level)

Remarks: This is just a work around and not an ideal solution. This won't version all assemblies in the project. For example if we want to know which assembly was built in which version, this not going to work. It is just place holder to get the build version of the solution.