I have a VS 2005 / MSBuild 2.0 project (let it be called "Project A"), which I have to save in VS 2005 (it uses the third-party constructor VS 2005.) Project A refers to one of the projects in my new VS 2008 solution (we we will call them Project C and Solution B, respectively.) Ideally, I would like to link the Project A building to the Solution B building, and I think the โToolsVersionโ attribute is the key. So, to repeat, this is what I need to do:
- Build solution B either through the command line or through Visual C # 2008 Express. It is imperative that it works through both !
- If project C starts project project A.
- Highlight the result of Project A (class library) in Project C.
- Create project C and other projects in solution B.
Here is the chart:
MSBuild 3.5 or VS2008->
[Solution In (3.5)] โ
[Project C (3.5)] โ
[Project A (2.0)] โ
Copy output A to C->
Continue Construction Solution B
Any ideas on how I should set this up? Clips from project work files would be greatly appreciated! Thanks in advance!
Decision
Here's what you need to add to Project C to make this work:
<ItemGroup> <ProjectToBuild Include="..\ProjectA\ProjectA.csproj" /> </ItemGroup> <Target Name="BeforeBuild"> <MSBuild Projects="@(ProjectToBuild)" Targets="Rebuild" ToolsVersion="2.0"> <Output TaskParameter="TargetOutputs" ItemName="AssembliesBuiltByChildProjects" /> </MSBuild> <Copy SourceFiles="@(AssembliesBuiltByChildProjects)" DestinationFolder="$(MSBuildProjectDirectory)" /> </Target>
Note that there is a known issue with getting TargetOutputs solutions with the MSBuild task. This should have been fixed in MSBuild 3.5, but I assume that the ToolsVersion attribute causes it to pop up. This is why I refer directly to ProjectA.csproj and not the solution file.
source share