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

推荐订阅源

量子位
Vercel News
Vercel News
Google DeepMind News
Google DeepMind News
罗磊的独立博客
WordPress大学
WordPress大学
The Cloudflare Blog
GbyAI
GbyAI
The Register - Security
The Register - Security
L
LangChain Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Microsoft Security Blog
Microsoft Security Blog
MyScale Blog
MyScale Blog
A
About on SuperTechFans
U
Unit 42
T
The Blog of Author Tim Ferriss
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
V
Visual Studio Blog
云风的 BLOG
云风的 BLOG
Stack Overflow Blog
Stack Overflow Blog
博客园 - 三生石上(FineUI控件)
博客园 - 司徒正美
Blog — PlanetScale
Blog — PlanetScale
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
T
The Exploit Database - CXSecurity.com
T
Tor Project blog
A
Arctic Wolf
H
Hacker News: Front Page
NISL@THU
NISL@THU
F
Full Disclosure
雷峰网
雷峰网
L
LINUX DO - 热门话题
Recent Announcements
Recent Announcements
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Apple Machine Learning Research
Apple Machine Learning Research
Google Online Security Blog
Google Online Security Blog
I
InfoQ
Webroot Blog
Webroot Blog
S
Security Affairs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
爱范儿
爱范儿
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
N
News | PayPal Newsroom
Forbes - Security
Forbes - Security
博客园 - Franky
V
Vulnerabilities – Threatpost
博客园 - 【当耐特】
Latest news
Latest news

博客园 - 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 
}