【问题标题】:How to change platformtarget for multiple projects and solutions?如何更改多个项目和解决方案的平台目标?
【发布时间】:2011-03-16 14:32:48
【问题描述】:
我正在使用 Visual Studio 2010 专业版。
我有许多将 PlatformTarget 设置为 x86 的项目和解决方案,我需要将其更改为 AnyCPU。
手动做是不可行的,因为项目太多,所以我想知道是否有一个现有的宏或脚本可以为所有项目自动转换。
如果没有这样的宏/脚本并且我必须自己编写转换应用程序,那么执行此转换的好方法是什么(在 csproj 文件中进行简单的字符串替换或有更好的方法)?
【问题讨论】:
标签:
visual-studio-2010
projects-and-solutions
platform
【解决方案1】:
Sub ChangePlatformTarget()
For Each proj As Project In DTE.Solution.Projects
Debug.WriteLine(proj.Name)
If Not proj.ConfigurationManager Is Nothing Then
ChangeProject(proj)
Else
'it's a folder, do something else with it...
End If
Next
End Sub
Sub ChangeProject(proj As Project
Dim prop As [Property] = proj.ConfigurationManager.ActiveConfiguration.Properties.Item("PlatformTarget")
prop.Value = "AnyCPU"
End Sub