Access Version from AssemblyInfo in MSBuild
assemblyinfo, msbuild, nuget-package
Solution
This i'll do it:
<PropertyGroup>
<MyAssemblies>somedll\the.dll</MyAssemblies>
</PropertyGroup>
<Target Name="RetrieveIdentities">
<GetAssemblyIdentity
AssemblyFiles="$(MyAssemblies)">
<Output
TaskParameter="Assemblies"
ItemName="MyAssemblyIdentities"/>
</GetAssemblyIdentity>
<Message Text="Files: %(MyAssemblyIdentities.Version)"/>
</Target>
Altered from here: MSBuild Task to read version of dll
Problem
I am trying to create/push nuget package through visual studio build process as explained here. Building package is easy: ``` <Exec WorkingDirectory="$(ProjectDir)" Command="$(NuGetApp) pack $(ProjectFile) -OutputDirectory $(Deploy) -Verbose -Prop Configuration=Release"/> ``` I see .nupkg file in $(Deploy) folder. But to be able to push it, I need $(AssemblyVersion) to use it in : ``` <Exec Command="$(NuGetApp) push $(ProjectName)$(AssemblyVersion) -s $(NugetServer) $(NugetKey)" /> ``` I tried XMLRead to fetch the value, but value in NugetSpecFile is "$version$" instead of version from AssemblyInfo.cs. ``` <XmlRead XPath="/package/metadata/version" XmlFileName="$(NuSpecFile)"> <Output TaskParameter="Value" PropertyName="AssemblyVersion" /> </XmlRead> ``` How do I access version so I could use it in "nuget push"?