Get assembly version information for multiple DLLs in MSbuild
All
It is quite convenient for me to write the assembly version information for a given project, which will be output as a DLL.
However, what I want to do now is go through each DLL in the \ Bin folder, get the Assembly information and write it to the version.txt file.
Has anyone been able to achieve a similar goal?
+1
source to share
1 answer
For this you can use the WriteVersionToFile
MSBuild target given below:
<PropertyGroup>
<VersionsFile>versions.txt</VersionsFile>
</PropertyGroup>
<ItemGroup>
<!-- Assemblies for which you want versions-->
<AssemblyFiles Include="Bin\**\*.dll"/>
</ItemGroup>
<Target Name="ExtractVersions">
<GetAssemblyIdentity AssemblyFiles="@(AssemblyFiles)">
<Output TaskParameter="Assemblies" ItemName="MyAssemblyIdentities"/>
</GetAssemblyIdentity>
<Message Text="%(MyAssemblyIdentities.Name) - Version %(Version)"/>
</Target>
<Target Name="WriteVersionToFile" DependsOnTargets="ExtractVersions">
<Delete Files="$(VersionsFile)" />
<WriteLinesToFile File="$(VersionsFile)"
Lines="%(MyAssemblyIdentities.Name) - %(Version)"
Overwrite="false"
Encoding="Unicode"/>
</Target>
The output file versions.txt
will look like this:
ICSharpCode.SharpZipLib - 0.85.4.369
nunit.framework - 2.4.7.0
Test.Rules - 0.2.0.0
+1
source to share