简体   繁体   中英

Using MSBuild to build VS .NET projects for VS 2003, VS 2005, and VS 2010

I'm a Unix CM geek, and know little about Microsoft .NET development. We now have a VisualStudio .NET project that we need to build. I want to use Jenkins to do the build. I had setup a previous VS project on another build server using Jenkins with Jenkins calling `msbuild.exe (version 3.5).

Currently, they build this project on their local desktops (oh, why do MS geeks think this is acceptable?). They do three builds: One in VS 2003, one in VS 2008, and one in VS 2010.

My thinking is that they simply don't understand what they're doing, or using those different versions of Visual Studio to build to different .NET versions. My questions:

  • Do I need VisualStudio installed in order to get msbuild.exe ? If not, where can I find it? The other build server I setup had VisualStudio .NET installed although it isn't used on our build box.
  • What version of msbuild.exe is for which version of the .NET framework and which version of VisualStudio? The other build box is using 3.5 which seems to work quite nicely for them.
  • Is there really a need to build all those different versions of the app?

You can build both VS 2008 and VS 2010 versions with the .Net 4.0 SDK by setting the TargetFrameworkVersion appropriately. I really do hope you meant that the oldest version used is VS 2005 (.Net 2.0), which also can be targeted using this method - if you really are using VS 2003 (targeting .Net 1.1) - you're out of luck, msbuild did not exist back then. But the dinosaurs did!

You can target a different .NET framework from Visual Studio 2010 or from msbuild. A build project can be setup to target .NET 2.0, .NET 3.5, and .NET 4.

That being said, if it's the same project, there is no real reason to do this. Unless the .NET 4 version is adding additional features, there is no reason to not just target .NET 2, and build a single deployment, since this can be used from .NET 3.5 and .NET 4 projects without issues.

I would recommend installing Visual Studio 2010, as this will get you the version of msbuild that can target all 3 frameworks.

Unfortunately, if you're targetting .NET 1.1 (2003), this will require a separate build, and the newer versions of Visual Studio only support .NET 2.0+.

即使没有MSBuild.exe,您仍然可以使用devenv.exe的命令行开关自动执行Visual Studio 2003的构建过程 - 请参阅MSDN上的标题为“在命令行上构建”的文章:http:// msdn.microsoft.com/en-us/library/f35ctcxw%28v=vs.71%29.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM