Skip to content

Instantly share code, notes, and snippets.

@trayburn
Last active December 17, 2015 05:18
Show Gist options
  • Save trayburn/5556633 to your computer and use it in GitHub Desktop.
Save trayburn/5556633 to your computer and use it in GitHub Desktop.
$project = ".\ConsoleApplication1.csproj"
$file = "<Compile Include='Models\NewClass.cs' />"
[xml](Get-Content $project) | `
Set-Variable -Name doc | `
Select-Xml "//x:ItemGroup[x:Compile]" -Namespace @{"x"=$doc.Project.xmlns} | `
Select-Object -ExpandProperty Node -First 1 | `
% { $_.InnerXml += $file; $doc.Save($project) }
@amirrajan
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment