Note that there are some explanatory texts on larger screens.

plurals
  1. POBuilding an MSBuild 2.0 project from 3.5
    text
    copied!<p>I have a VS 2005/MSBuild 2.0 project (let's call it "Project A") that I <em>must</em> keep in VS 2005 (it uses a third-party VS 2005 Designer.) Project A is referenced by one of the projects in my new VS 2008 solution (we'll call them "Project C" and "Solution B" respectively.) Ideally, I'd like to chain the building of Project A into the building of Solution B, and I believe that the "ToolsVersion" attribute is the key. So, to recap, this is what I need to do:</p> <ol> <li>Start a build on Solution B either through the command-line or Visual C# 2008 Express. It is critical that it work through <strong>both</strong>!</li> <li>Have Project C trigger the building of Project A.</li> <li>Have the output of Project A (a class library) copied to Project C.</li> <li>Build Project C and the remaining projects in Solution B.</li> </ol> <p>Here's a diagram:<br> MSBuild 3.5 or VS2008-><br> [Solution B (3.5)]-><br> [Project C (3.5)]-><br> [Project A (2.0)]-><br> Copy output of A to C-><br> Continue building Solution B</p> <p>Any ideas on how I should set this up? Clips from working project files would be hugely appreciated! Thanks in advance!</p> <p><strong>SOLUTION</strong><br> Here's what needed added to Project C, to make this work:</p> <pre><code>&lt;ItemGroup&gt; &lt;ProjectToBuild Include="..\ProjectA\ProjectA.csproj" /&gt; &lt;/ItemGroup&gt; &lt;Target Name="BeforeBuild"&gt; &lt;MSBuild Projects="@(ProjectToBuild)" Targets="Rebuild" ToolsVersion="2.0"&gt; &lt;Output TaskParameter="TargetOutputs" ItemName="AssembliesBuiltByChildProjects" /&gt; &lt;/MSBuild&gt; &lt;Copy SourceFiles="@(AssembliesBuiltByChildProjects)" DestinationFolder="$(MSBuildProjectDirectory)" /&gt; &lt;/Target&gt; </code></pre> <p>Note there is a <a href="http://social.msdn.microsoft.com/forums/en-US/msbuild/thread/4ca448c3-d571-4a4b-b96e-755309cd1a97/" rel="nofollow noreferrer">known issue</a> with getting the TargetOutputs of a solution with the MSBuild task. This was supposed to be fixed in MSBuild 3.5, but I'm guessing that the ToolsVersion attribute is causing it to resurface. That's why I'm referencing ProjectA.csproj directly, instead of its solution file.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload