惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MyScale Blog
MyScale Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
人人都是产品经理
人人都是产品经理
V
Visual Studio Blog
博客园 - 叶小钗
A
About on SuperTechFans
Last Week in AI
Last Week in AI
量子位
博客园 - 三生石上(FineUI控件)
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
MongoDB | Blog
MongoDB | Blog
T
The Blog of Author Tim Ferriss
Vercel News
Vercel News
博客园 - 司徒正美
博客园 - Franky
博客园 - 【当耐特】
月光博客
月光博客
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Apple Machine Learning Research
Apple Machine Learning Research
Hugging Face - Blog
Hugging Face - Blog
S
SegmentFault 最新的问题
大猫的无限游戏
大猫的无限游戏
博客园 - 聂微东
J
Java Code Geeks

博客园 - Asharp

PowerShell因为在此系统中禁止执行脚本解决方法 .NET中zip的压缩和解压——SharpCompress .NET中zip的压缩和解压 【转】Face detection with getUserMedia 【转】Web实现音频、视频通信 【转】关于IPv6的六大误区:IPv6并非更安全 【转】Silverlight与Flex的比较选择 [转]12 很有用的 Chrome 浏览器命令 How to Set Up SSL on IIS 7 JavaScript实现md5加密 在64位系统32的.net应用程序出现CLR20R3错误 【转】CLR20R3 程序终止的几种解决方案 【转】ASPxGridView 日期范围过滤扩展 DevExpress的web.config配置 DevExpress的JavaScript脚本智能提示 加载托管C++程序集出现0x800736B1异常的解决方法 Exchange server 2007安装篇 使用Orca在Visual Studio安装项目中创建自定义对话框 Visual Assist X中文注释提示错误问题
使用PowerShell批量修改项目文件的版本号
Asharp · 2012-06-01 · via 博客园 - Asharp

      在有些项目中,解决方案中包含有很多项目文件(类库、应用程序等),一个个修改AssemblyInfo.cs文件的版本信息很麻烦。

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Build and Revision Numbers 
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
 

        将下面的代码保存为ps1文件,放到和解决方案同一目录下:

#获取解决方案的目录
$SolutionPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
#获取所有的AssemblyInfo.cs文件
$FileList = Get-ChildItem $SolutionPath -Recurse AssemblyInfo.cs
$oldVersion = "Version\(""\d{1,}.\d{1,}.\d{1,}.\d{1,}""\)"
$newVersion = "Version(""1.1.1.1"")"
Foreach($filename in $FileList)
{
    $filename = $filename.FullName 
    (Get-Content $filename) |  
    Foreach-Object { $_ -replace $oldVersion, $newVersion } |  
    Set-Content $filename 
}