I was recently attempting to build documentation for a few projects using Sandcastle, a free engine provided by Microsoft that compiles documentation with a MSDN look and feel from managed class libraries and projects. Sandcastle doesn't have a GUI or command-line interface built-in, so I used the Sandcastle Help File Builder, which is an open source project. If I used a dll as the documentation source, it was able to build the documentation ... but you are also supposed to be able to reference a project (e.g. a file with a .csproj extension), but when I tried to do that instead of the dll I got this error:
SHFB: Error BE0065: BUILD FAILED: The imported project "C:\Program Files\MSBuild\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. C:\...\XXX.csproj
I googled this error (like you probably did), and found this post about multi-targetting that seemed unrelated at first ... but turned out to kind of be the answer. It suggested replacing the typical import statement in the .csproj file with one that included conditions, which allows the project to automatically determine which Microsoft.WebApplication.targets file to reference based on the environment.
To fix it, I just opened the .csproj file with Notepad, and removed the existing import statement related to Microsoft.WebApplication.targets (towards the bottom of the file), and replaced it with two import statements that included the conditions.
Replace This Line:
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
With These Lines:
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v8.0\WebApplications\Microsoft.WebApplication.targets" Condition="'$(Solutions.VSVersion)' == '8.0'" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" Condition="'$(Solutions.VSVersion)' == '9.0'" />
After that it built fine with just the reference to the project file instead of the actual dlls. This is a good thing, and here is a tip from the Sandcastle Help File Builder documentation that explains why this is better than referencing the dlls directly:
Given that solutions and projects are supported as documentation sources, you may find it easier to add them as documentation sources instead of the assemblies, comments, and references that they contain. When a solution or project is used, these items are imported from them automatically at build time.