从MSBuild中的AssemblyInfo访问版本 [英] Access Version from AssemblyInfo in MSBuild
本文介绍了从MSBuild中的AssemblyInfo访问版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试通过Visual Studio构建过程来创建/推送nuget包,如
I am trying to create/push nuget package through visual studio build process as explained here.
构建程序包很简单:
<Exec WorkingDirectory="$(ProjectDir)" Command="$(NuGetApp) pack $(ProjectFile) -OutputDirectory $(Deploy) -Verbose -Prop Configuration=Release"/>
我在$(Deploy)文件夹中看到.nupkg文件.
I see .nupkg file in $(Deploy) folder.
但是要能够推送它,我需要$(AssemblyVersion)才能在其中使用它:
But to be able to push it, I need $(AssemblyVersion) to use it in :
<Exec Command="$(NuGetApp) push $(ProjectName)$(AssemblyVersion) -s $(NugetServer) $(NugetKey)" />
我尝试使用XMLRead来获取值,但是NugetSpecFile中的值为"$ version $",而不是AssemblyInfo.cs的版本.
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>
如何访问版本,以便可以在"nuget push"中使用它?
How do I access version so I could use it in "nuget push"?
推荐答案
我将这样做:
<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>
从这里更改: 用于读取dll版本的MSBuild任务
这篇关于从MSBuild中的AssemblyInfo访问版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文