.NET程序编译版本维护
来源:互联网 发布:qq for linux安装教程 编辑:程序博客网 时间:2024/05/17 14:25
1、 工具-宏-新建宏项目
2、 将Model1.vb重命名为AutoBuildVersion.vb
添加此事件到原生成文件中
Private Sub BuildEvents_OnBuildBegin(ByVal Scope As EnvDTE.vsBuildScope, ByVal Action As EnvDTE.vsBuildAction) Handles BuildEvents.OnBuildBegin Call AutoBuildVersion() End Sub
然后拷贝如下代码到AutoBuildVersion.vb中
Imports SystemImports EnvDTEImports System.DiagnosticsPublic Module BuildVersion '得到项目所在目录 Function GetProjectDir(ByVal FullName) Dim proj_path proj_path = Split(StrReverse(FullName), "\", -1, 1) Dim count count = UBound(proj_path) Dim full_path full_path = "" Dim i For i = 1 To count full_path = full_path & "\" & proj_path(i) Next GetProjectDir = StrReverse(full_path) End Function ' This event will be triggered after every build of a project ' You can modify the code below to only update projects that are active ' It currently will scan all projects in the solution for AssemblyInfo.vb files ' to update. Sub AutoBuildVersion() 'Comment the follow 3 lines, if you want the build number to increment even if the build fails If DTE.Solution.SolutionBuild.LastBuildInfo() <> 0 Then Exit Sub End If ' Change this, if you would only like to modify the AssemblyInfo file in active project files ' For Each proj As Project In DTE.ActiveSolutionProjects For Each proj As Project In DTE.Solution.Projects Dim full_path full_path = GetProjectDir(proj.FullName) ' Attempt to open the AssemblyInfo.vb file full_path = full_path & "Properties\AssemblyInfo.cs" Try DTE.ItemOperations.OpenFile(full_path).Activate() Dim activeDoc As Document = DTE.ActiveDocument Dim objSelection As TextSelection objSelection = DTE.ActiveDocument.Selection Dim objStartPosition As Integer ' Get the text between AssemblyVersion(" and ") objSelection.FindText("AssemblyFileVersion(""") objStartPosition = objSelection.BottomPoint.DisplayColumn Dim objEndPosition As Integer objSelection.FindText(""")") objEndPosition = objSelection.AnchorPoint.DisplayColumn ' Get back to after the AssemblyVersion" part objSelection.StartOfLine() objSelection.FindText("AssemblyFileVersion(""") objSelection.Collapse() objSelection.MoveToDisplayColumn(0, objEndPosition, True) objSelection.Text = Now.ToString("yyyy.MM.dd.HHmm") activeDoc.Close(vsSaveChanges.vsSaveChangesYes) Catch End Try Next End SubEnd Module
运行效果图
- .NET程序编译版本维护
- 使用@Page指令的Src属性简化对老版本的asp.net程序的维护
- 程序升级/维护过程中,版本控制
- .NET程序编译原理
- ASP.NET程序维护--如何远程更新客户程序
- .net程序版本兼容性解决
- 针对不同.NET版本的条件编译
- 针对不同.NET版本的条件编译
- .NET概念:.NET程序编译和运行
- DDK编译的程序增加版本信息
- 若要针对 .NET Framework 4.0 或更高版本进行编译,则提供程序选项中“compile
- 版本维护工具
- linux 版本维护
- 将PC版本的QT程序编译为ARM版本
- NET framework 不懂版本的 程序运行
- 程序集强签名-.net版本问题
- mac xcode7编译老版本程序程序出错
- 如何利用SDK来编译.Net程序?
- ASP.NET程序也能像WinForm程序一样运行
- flex与java交互:RemoteObject
- JS Date格式化为yyyy-mm-dd类字符串
- 10月28日 总结前些天
- mysql 的table合并
- .NET程序编译版本维护
- linux下 C语言对 php 扩展
- shell脚本解析XMl文件
- bada学习-(三)架构
- MFC的消息机制
- [2-sat][裸题] HDU3062 Party
- 天下万物皆有定时
- django south [app]
- [iphone/ipad]Code Sign error: Provisioning profile XXXX can't be found