I would like to be able to specify the version number for all assemblies to be generated during a build as a MSBuild command argument like this:
MSBuild.exe /p:version=5.4.3.0
I have looked over AssemblyInfoTask
but it does not seem to me like a good solution in this case.
I use the AssemblyInfo task from MSBuild Community Tasks (latest release 2017) as you describe in your comment all the time.
<!-- update standard assembly attribute in all projects -->
<Target Name="BeforeBuild" >
<Message Text="Updating AssemblyInfo to Version $(VersionNumber)"></Message>
<Message Text="Writing to AssemblyInfo files in $(SolutionRoot)"></Message>
<AssemblyInfo AssemblyInfoFiles="@(AssemblyInfoFiles)"
AssemblyCopyright="$(AssemblyCopyright)"
AssemblyVersion="$(VersionNumber)"
AssemblyFileVersion="$(VersionNumber)"
>
</AssemblyInfo>
</Target>
The VersionNumber value is passed from outside the MSBuild project file exactly as you describe:
MSBuild <project_file> /p:VersionNumber=<value>;...
We use the BeforeBuild target to ensure the AssemblyInfo.cs files all get worked on before the build starts. Is this not what you want?