Last active
December 11, 2015 13:04
-
-
Save masaru-b-cl/1e6e849ffe8cf0d9a9fb to your computer and use it in GitHub Desktop.
プロジェクトファイルを舐めて書き換えるLinqPadスクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
XNamespace ns = "http://schemas.microsoft.com/developer/msbuild/2003"; | |
var filenames = Directory.EnumerateFiles( | |
@"C:\Users\takano-s\src", | |
"*.vbproj", | |
SearchOption.AllDirectories); | |
foreach(var filename in filenames) | |
{ | |
var doc = XDocument.Load(filename); | |
// OutputPathプロパティの書き換え | |
new List<String>(new[]{"Debug", "Release"}).ForEach(condition => | |
{ | |
var outputPath = doc.Descendants(ns + "OutputPath") | |
.Where(e => e.Ancestors(ns + "PropertyGroup") | |
.First() | |
.Attribute("Condition").Value | |
.Contains(condition)) | |
.First(); | |
outputPath.Value = String.Format(@".\bin\{0}\", condition); | |
}); | |
// propsファイルのインポート | |
doc.Root.Add( | |
new XElement(ns + "Import", | |
new XAttribute("Project", @"$(ProjectDir)..\path\to\Proj.Common.props") | |
) | |
); | |
doc.Save(filename); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment