.NET Framework Bookmark and Share   
 index > MSBuild > Using MSBuild 2.0 to build 3.5 projects
 

Using MSBuild 2.0 to build 3.5 projects

I have a .NET 3.5 solution with several .NET 3.5 projects, but another project required to be referenced is a 2.0 project. That project must remain buildable in an MSBuild 2.0 build (it is a library common to several solutions, some of which are 2.0). I wantto maintain an existing automatic 2.0 build process as well as add the 3.5 build of the project to the 3.5 solution.

One solution is to build into the 3.5 build scripts an MSBuild task that specifies the tools version of 2.0 and then copies the resulting binaries to be referenced by the 3.5 projects being built in the subsequent MSBuildtask. For reasons I won't go into I don't want to do that, but am wondering if the following will work:

If I get VS2008 to convert the 2.0 project file to 3.5 then that project file gets a couple of changes (the ToolsVersion attribute, and some elements with 'upgrade' in their name). That file, though, appears to be handled OK with MSBuild 2.0 and can be loaded into a VS2005 solution. I understand that solution files converted to the later MSBuild causes MSBuild 2.0 to error, but are 2.0 project files that have been converted to 3.5 still compatible with MSBuild 2.0 and VS2005? Also, it appears that if I then load the project into vs2005 and cause vs2005 to re-write that file (e.g. I play around with the project properties, settings etc...) then the new attribute (ToolsVersion) and elements ('...upgrade...') remain in the file. Can that be guaranteed?

Thanks,
John
JohnDJJ

Hi, John

I am a little puzzled about what do you want. Does your 2.0 project is created by VS2005?
For VS2008you can keep both of the 3.5 and 2.0 project in a solution, and they are automatic when you build your solution.
"If I get VS2008 to convert the 2.0 project file to 3.5" , do you mean convert to vs2005 project to vs 2008 project?For in VS2008, you can convert the 2.0 project to 3.5 Just simply click Application Tab, and then select Target Framework in the property page.
You are not able to open the solution by VS2005 after it has converted to the VS2008 directly. You should convert it manually, for more information you can reference Visual Studio 2005/2008 Interoperability .
If I misunderstood you, or have something unclear, feel free to let me know.
Thanks
Hope this could help!
Chao
This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

Chao Kuo
Hi Chao,

Many thanks for your reply. Much appreciated.

Perhaps my post wasn't clear about my intention.

I have a VS2005 project that I want to keep as a VS2005 project. I want to be able to a) use it in VS2005 and b) use it in MSBuild 2.0 scripts.
But I also have a VS2008 project (solution) that is using that project (currently referencing the dll built by the VS2005 project). I want that VS2008 solution to be able to reference the VS2005 project. And I want my build scripts, written for MSBuild 3.5, to be able to include the building of the VS2005 project (I know MSBuild can be told to use 2.0 tools, but there may be a need to have MSBuild 2.0 use the converted file).

I hope that is clear.

Now, if I try to load the VS2005 project into VS2008 then the project conversion wizard starts (understandably). If I let the wizard convert the project (I'm only interested in the proj file conversion) then I end up with a slightly modified file. That modified file can, interestingly, still be used in VS2005 and MSBuild 2.0. Also, if I make a change to the project's properties when the project is loaded in VS2005 then the changes made during the conversion process remain. All of this is what I want. I can now use that project in both VS2008 and VS2005 and both MSBuild 2.0 and MSBuild 3.5.

I am only willing to use this way forward, though, if I can be reasonably confident that I can trust this behaviour. I have many such VS2005 projects that need to remain available as VS2005 projects during a potentially long upgrade process to VS2008, whilst those projects are being used in both VS2005 and VS200.

My question is, can I be confident that I can get VS2008 to convert the VS2005 project files and then still be able to use those project files in VS2005 (and MSBuild 2.0)?

Interestingly, I tried the project converter you referenced. It came up with different results to the conversion produced in VS2008. Firstly, it changed the Product Version (understandably) to 9.whatever, whereas VS2008's wizard did not change that value. Secondly, it changed the environment variable that is used to reference Microsoft.CSharp.targets, whereas VS2008's wizard didn't. After that second change the project no longer loaded in VS2005 - it errored.

If my question is now clear and can be answered then fantastic.
Thanks for your time
John
JohnDJJ
Hi, John

Thanks for your following up. And I totally understand you this time.
For the convertion from VS2008 project to vs2005 project, the slightly changedoes't effect the compilation of MSBuild 2.0. But You can not use the solution file after it has converted, since it has changed a lot after convertion. So you should confident about the change.
Thanks
Chao
Chao Kuo

You can use google to search for other answers

Custom Search

More Threads

• Start Installation of msi-package with command
• Invoking MSBUILD from Inside an App
• Long Question...sorry
• Best practices for MSBuild
• Getting the Error "Object reference not set to any instance of object" when i am viewing the code from the designer in C# vs 2008
• Passing values from MSBuild to VCBuild
• API for getting PerformanceSummary from MSBuild
• msbuild - update xml file
• Error with Computed field using VS2005
• Call PostBuildEvent.bat in PostBuildEvent