Access to $project in install.ps1 in a web site project?

Feb 20, 2011 at 6:29 PM

I like to do a few things in install.ps1, but all the properties of $project seem to be empty when running the package against a web site project type.

I guess that is because a "web site" isn't a "real" project in VS.

To get the location of the web site on disk I am using the following:


foreach($pro in $DTE.Solution.Projects)
    if ($pro.Type -eq "Web Site")
         $projectLocation = $pro.FullName

is there a better way? Any plans to improve web site support in future versions?


Feb 20, 2011 at 7:29 PM

Generally for websites you have to deal with it differently than other projects. We are planning to add a Powershell helper library to help ease common tasks of dealing with DTE operations.

May 13, 2013 at 12:19 PM
I have the same problem.
I want to get the location of the web site on the disk but $project.FullName returns 'http://xxxxxxxxxxx'.
Is it possible to get the physical path to the project on the disk when the project is a web site?
May 13, 2013 at 8:07 PM
Try this:

May 14, 2013 at 12:01 PM
Ok, this code returned the path to the project. But there is a strange behavior when using PowerShell script in website project. Now when I try to remove item from a project, it throws an error. I'm trying the following:

$project.ProjectItems | ForEach { if ($_.Name -eq "SomeFile.txt") { $_.Remove() } }

This code works when the project is not a website, but when I'm using website project, it throws the following:

"Remove" with "0" argument(s): "'Remove' not applicable for this ProjectItem."
The text file is there but Remove method is not working.