私はこのコードを持っています:
function setupProject($projectFile) {
[xml]$root = Get-Content $projectFile;
$project = $root.Project;
$beforeBuild = $root.CreateElement("Target", "");
$beforeBuild.SetAttribute("name", "BeforeBuild");
$beforeBuild.RemoveAttribute("xmlns");
$project.AppendChild($beforeBuild);
$root.Save($projectFile);
}
XMLドキュメントに新しいものを追加する必要があります。<Target name="BeforeBuild" />
xmlns=""
しかし、それは私が望まない空の属性も追加します。(実際には、この属性が気に入らないのはVisual Studioです!)
<Target name="BeforeBuild" xmlns="" />
私はすでにこのコードを試しました:
$beforeBuild.RemoveAttribute("xmlns");
$project.AppendChild($beforeBuild);
$beforeBuild.RemoveAttribute("xmlns");