Web Deployment Project frustration turning to enlightenment.
Thanks to some great suggestions by Scott and others I have put aside any fears/laziness of delving into the msbuild script and managed to come up with an alternate way of changing web.config settings as part of the build process. While the web.config replacement stuff works for me at the moment, I like having this method around since it can be used to vary any kind of output as part of the build.
There are 2 parts of the Deployment script that are usefull for varying the output of the build. First is the ExcludeFromBuild item. I used it to exclude all the web.config variations in the project since I will manually copy the production version of the web.config as a later step. To do this just create a <itemgroup> and throw in the excludes like this:
1: <ItemGroup>
2: <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\web.config" />
3: <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\prodweb.config" />
4: </ItemGroup>
Second, there's the BeforeBuild target. I use this target to copy the production version of the web.config to the build output. The two variables that are needed to do this are $(SourceWebPhysicalPath) and $(CopyBeforeBuildTargetPath).
1: <Target Name="BeforeBuild">
2: <Copy
3: SourceFiles="$(SourceWebPhysicalPath)\prodweb.config"
4: DestinationFiles="$(CopyBeforeBuildTargetPath)\web.config"
5: />
6: </Target>
Lesson learned: Don't let laziness or fear deter you from MSBuild. It really didn't take that long to figure out what was going on and where I could "plug-in". This is just the most basic implementation of this idea. You can also get more advanced and create different types of build and copy diff versions of files based on what build type is being performed (Debug/Release/Staging/Production/Test etc).