c# - How do I get just the Major part of version inside AfterBuild target
问题描述
How do I get just the Major
part of the version in AfterBuild target? I thought I could access the property like shown below, but it just echoes the statement rather than show version.
<Target Name="AfterBuild">
<GetAssemblyIdentity
AssemblyFiles="$(MyAssemblies)">
<Output
TaskParameter="Assemblies"
ItemName="MyAssemblyIdentities"/>
</GetAssemblyIdentity>
<Message Text="Files: %(MyAssemblyIdentities.Version.Major)"/>
</Target>
Here is the working code in Program.cs
var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
Console.WriteLine(String.Format("My Application Version {0}", version.Major));
解决方案
推荐阅读
- c# - Parallel.Foreach 在 Linux 机器上失败,但在 Windows 机器上工作
- ruby-on-rails - 如何使我的助手代码更苗条?
- c - CPU1 上线失败
- python - 使用 beautifullSoup 从隐藏形式中获取多重价值
- javascript - NVD3 内存泄漏问题
- sql-server - MS SQL 2019 中的 UDF 内出现意外的 @@rowcount 行为
- postgresql - PostgreSQL:后台工作人员“逻辑复制启动器”以退出代码 1 退出
- javascript - 如何使用fabricjs从图像和边框图像中实现相框?
- javascript - 时刻 JS 获得一年中第一周的正确周数
- java - 如何在 Activity 类中启用 xml 按钮?