Delete file before installing a package

Dec 26, 2011 at 10:59 AM

I'm trying to delete the web.config before installing a package but it does not
recognize the command -> Get-ProjectItem
 

"Get-ProjectItem" web.config "|% {$ _.Delete ()}"

 

 This command run in install.ps1 file.


I do some configuration?


Jan 4, 2012 at 6:36 PM
#file install.ps1
Function Get-ProjectItem ($project, $nome)
{
	#verifica se o nome do item contém "\"
	if($nome.Contains("\"))
	{
		$Item = $nome.substring(0,$nome.IndexOf('\'))
		$nome = $nome.substring($nome.IndexOf('\')+1)
		$proj = $project.ProjectItems.Item($Item)
		
		Get-ProjectItem -project $proj -nome $nome		
	}
	else
	{
		return $project.ProjectItems.Item($nome)
	}
}
 
$x = Get-Project
 
Get-ProjectItem –project $x –nome "Default.aspx" | %{ $_.Delete() }

#Credits Ciro Lemos
Developer
Jan 4, 2012 at 7:08 PM

Have a look at this gist - https://gist.github.com/984358#file_project_item+recursion