我正在使用 Msbuild 编译和生成 .zip 文件和安装程序,我需要我的 assembyInfo 的版本号.
I'm using Msbuild to compile and generate .zip files and installers and I need the version number of my assembyInfo.
我正在使用此代码.
<Target Name="getversion">
<GetAssemblyIdentity AssemblyFiles="$(BuildDir)myprogram.exe">
<Output TaskParameter="Assemblies" ItemName="fooAssemblyInfo"/>
</GetAssemblyIdentity>
<Message Text="Version = %(fooAssemblyInfo.Version)"/>
</Target>
但这返回版本 = 2.0.0.29110,我只需要次要和主要版本.
But this returns Version = 2.0.0.29110, I need just the minor and major version.
有没有什么方法可以在没有自定义任务的情况下读取 assembyInfo.cs 信息?
Is there any way to read the assembyInfo.cs information without a custom task?
终于用上了这段不需要额外任务库的代码
Finally I have used this code that not require additional task libraries
<Target Name="getversion">
<GetAssemblyIdentity AssemblyFiles="$(BuildDir)myfile.exe">
<Output TaskParameter="Assemblies" ItemName="myAssemblyInfo"/>
</GetAssemblyIdentity>
<PropertyGroup>
<Pattern>(d+).(d+)</Pattern>
<In>%(myAssemblyInfo.Version)</In>
<OutVersion>$([System.Text.RegularExpressions.Regex]::Match($(In), $(Pattern)))</OutVersion>
</PropertyGroup>
</Target>
这篇关于从 MSBUILD 脚本获取次要版本和主要版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
有没有办法知道是否有人为您的网站添加了书签Is there a way to know if someone has bookmarked your website?(有没有办法知道是否有人为您的网站添加了书签?)
使用不同的 .Net 语言?Use of Different .Net Languages?(使用不同的 .Net 语言?)
确定 ASP.NET 站点的“活动"用户数Determining an #39;active#39; user count of an ASP.NET site(确定 ASP.NET 站点的“活动用户数)
跟踪当前在线用户的最佳方式Best way to keep track of current online users(跟踪当前在线用户的最佳方式)
推荐一个开源的.NET统计库Recommend an Open Source .NET Statistics Library(推荐一个开源的.NET统计库)
给定轮班列表,创建时间表的摘要描述Create a summary description of a schedule given a list of shifts(给定轮班列表,创建时间表的摘要描述)