As a rule, the build dlls part is the most difficult part. If you succeed, you are 80% there. The other half is content publishing. In it the most elementary aspect, you copy part of the files from the source directory to the website folder. MSDeploy is Microsoft's answer to it, and it is waaaaaay too complex. I created an NAnt task that does this, although this also does not apply to your specific scenario. However, a general methodology may:
Scan the sln file looking for web projects. What does a web project do? Technically, the guides are in the csproj file or the project type identifier in the sln file. I tricked and identified it as "the destination folder contains the web.config file." If your solution has only one website project, you can skip this step and simply copy the .csproj file.
Scan the csproj file for <Content Include="some\file.ext" /> nodes. XPath can do this, Linq to XML can do this. This gives you all .aspx, .cshtml, .js, .css, .png, .config, etc. Etc. Carefully leaving all .cs files. You will need to prefix the path to the .csproj file to get the true location of the source file, and you want you to keep the folder structure in the destination. But this is trivial compared to collecting a list of files.
Now that you have the list of files, skip copying it from the source folder to the destination folder. (You probably want to either clear the destination folder first, or then delete the extra files from previous deployments. I think the first is easier.) The only thing that scanning the csproj file did not give you is the contents of the bin folder, but this cake: copy all contents folders bin .: D (There is a healthy discussion about whether to copy .pdb files, but I say yes.)
Create a script to complete the above 3 steps, then call it either from the XBuild task, or call XBuild and this script from the CI process. Poof. You have a deployment goal. Happy coding!
source share