Creating an MSBuild 2.0 Project with 3.5

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.

+4
source share
4 answers
  • Make sure that project C is a dependency on project B. (In this case, there is no project B, but if it was then, make sure.)
  • Edit the C proj project file in a text editor. Add the following value to the end of the file, but before the closing project tag, where a.sln is the solution for project A.

    <ItemGroup>
    <ProjectsToBuild Include = "a.sln" />
    </ItemGroup>
    <Target Name = "BeforeBuild">
    <Msbuild
    projects = "@ (ProjectsToBuild)"
    Goals = "Build" ToolsVersion = "2.0">
    <exit
    TaskParameter = "TargetOutputs"
    ItemName = "AssembliesBuiltByChildProjects" />
    </MSBuild>
    <Copy SourceFiles = "@ (TargetOutputs)"
    DestinationFolder = "@ (SolutionDir) \ References"
    />
    </ Target>

  • Create a help folder under your solution and make sure that it is marked as a help folder for project C.

  • Build Project B.

I have not tested it, but the concept should work.

+2
source

You did not indicate why you need to use Visual Studio 2005 in this project. (I know there are good reasons for this, but they may involve different decisions.)

What I once successfully executed was to set the binary, include and library paths in VS2008 to use the compiler and includes vs2005 (it was a win32 C ++ project).

You can remove / nologo from the compiler options to actually see the version of the compiler used.

METHODICAL:

  • Copy and rename the 2005 project before converting it to 2008. (to have a clean 2005 version)
  • Add a new converted project to the solution 2008, install the dependencies.

  • Add the property-page-thingy (I donโ€™t know that it is called in English, this is a .vsprops file) to the version of the draft version of version 2008 with the sets of binary, prefabricated and included directories installed with the 2005 installation , thereby forcing vs2008 to use the 2005 toolbox for this project. You may need the professional version of vs2008 to create such a file, but all versions should be able to read it)

In principle, for this project you will only use the 2008 editor component and the 2005 compiler.

There may be better solutions, but since you have no answers yet, I suggest this workaround.

+1
source

How about this: Edit the project C proj file to include the Exec MSbuild task, which calls VS2005 devenv with the / build switch to build project A, and then copy the output files from project A to the location where project C can be found. You need to take a step builds in the C proj project file before C is compiled, possibly BeforeBuild so that C can find the result of project A.

+1
source

Only the SLN format is different from VS2008, the CSPROJ / VBPROJ files "can" remain the same ... Thus, basically you will need two SLN files to add your CSPROJs / VBPROJ to both SLNs.

Read more at http://weblogs.asp.net/palermo4/archive/2007/07/30/managing-projects-in-visual-studio-2005-amp-2008.aspx .

+1
source

All Articles