The final, reusable solution is as follows.
Recap:
I have several sites in a root folder who's directories and project file names are all named the value of the website. I want to be able to publish all sites (or a selected list) from the command line - running a script. The websites are then to be published to my IIS server directories.
First, create a MSBuild script that takes in the parameter of the website name:
<?xml version="1.0" encoding="utf-8" ?>
<Project DefaultTargets="Compile,Deploy" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name ="DeleteFiles">
<Delete Files="..\$(ProjectName)\$(ProjectName)\obj\debug\$(ProjectName).dll"></Delete>
<Delete Files="..\$(ProjectName)\$(ProjectName)\obj\release\$(ProjectName).dll"></Delete>
<Delete Files="..\$(ProjectName)\$(ProjectName)\bin\$(ProjectName).dll"></Delete>
<Delete Files="..\$(ProjectName)\$(ProjectName)\bin\$(ProjectName).pdb"></Delete>
</Target>
<Target Name="Compile" DependsOnTargets="DeleteFiles">
<MSBuild Projects="..\$(ProjectName)\$(ProjectName)\$(ProjectName).csproj"
Targets="Clean;Build"
Properties="OutputPath=..\$(ProjectName)\bin"/>
</Target>
<Target Name="Deploy" DependsOnTargets="Compile">
<MSBuild Projects="..\$(ProjectName)\$(ProjectName)\$(ProjectName).csproj"
Targets="ResolveReferences;_CopyWebApplication"
Properties="OutDir=C:\inetpub\wwwroot\$(ProjectName)\bin\;WebProjectOutputDir=C:\inetpub\wwwroot\$(ProjectName)" />
</Target>
</Project>
Next, create a text file with one website name per line. This can be easily generated by doing a "dir > sites.txt" then column editing out superfluous content.
ie.
site1.com
site2.com
site3.com
site4.com
Lastly, create a batch file that iterates through the list contained in sites.txt, and executes the MSBuild script:
@echo --------------------------------------------
@echo -- Iterating through list in sites.txt --
@echo --------------------------------------------
for /f %%X in (sites.txt) do msbuild build.xml /p:ProjectName="%%X" /v:n
This solution resides on in a directory on the same level as the rest of the websites from the root, which why the "..\$(ProjectName)" in the build script.
Great way of publishing a bunch of sites, and hope this helps someone.