Skip to content

Instantly share code, notes, and snippets.

@sliekens
Created July 9, 2015 11:07
Show Gist options
  • Save sliekens/746ebc75cb137e778684 to your computer and use it in GitHub Desktop.
Save sliekens/746ebc75cb137e778684 to your computer and use it in GitHub Desktop.
migrateToAutomaticPackageRestore
$files = gci -Recurse *.csproj
$files | %{
$file = $_
$xml = [Xml](Get-Content $file)
$nsm = [Xml.XmlNamespaceManager]$xml.NameTable
$nsm.AddNamespace('msb', $xml.DocumentElement.NamespaceURI)
$restorePackages = $xml.SelectSingleNode('//msb:RestorePackages', $nsm)
$restorePackages.ParentNode.RemoveChild($restorePackages)
$nugetTarget = $xml.SelectSingleNode('//msb:Target[@Name="EnsureNuGetPackageBuildImports"]', $nsm)
$nugetTarget.ParentNode.RemoveChild($nugetTarget)
$nugetImport = $xml.SelectSingleNode('//msb:Import[contains(@Project, ".nuget\NuGet.targets")]', $nsm)
$nugetImport.ParentNode.RemoveChild($nugetImport)
$xml.Save($file)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment