简体   繁体   English

使用MSBuild为VS 2003,VS 2005和VS 2010构建VS .NET项目

[英]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. 我是Unix CM的极客,对Microsoft .NET开发知之甚少。 We now have a VisualStudio .NET project that we need to build. 我们现在有一个我们需要构建的VisualStudio .NET项目。 I want to use Jenkins to do the build. 我想用Jenkins做构建。 I had setup a previous VS project on another build server using Jenkins with Jenkins calling `msbuild.exe (version 3.5). 我使用Jenkins和Jenkins调用`msbuild.exe(版本3.5)在另一个构建服务器上设置了一个以前的VS项目。

Currently, they build this project on their local desktops (oh, why do MS geeks think this is acceptable?). 目前,他们在本地桌面上构建这个项目(哦,为什么MS极客认为这是可以接受的?)。 They do three builds: One in VS 2003, one in VS 2008, and one in VS 2010. 他们做了三个版本:一个在VS 2003中,一个在VS 2008中,一个在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. 我的想法是他们根本不理解他们正在做什么,或者使用不同版本的Visual Studio来构建不同的.NET版本。 My questions: 我的问题:

  • Do I need VisualStudio installed in order to get msbuild.exe ? 我是否需要安装VisualStudio才能获得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. 我设置的另一个构建服务器安装了VisualStudio .NET,虽然它没有在我们的构建盒上使用。
  • What version of msbuild.exe is for which version of the .NET framework and which version of VisualStudio? 什么版本的msbuild.exe适用于哪个版本的.NET框架以及哪个版本的VisualStudio? The other build box is using 3.5 which seems to work quite nicely for them. 另一个构建框使用3.5,它似乎对它们非常好用。
  • 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. 您可以通过适当设置TargetFrameworkVersion ,使用.Net 4.0 SDK构建VS 2008和VS 2010版本。 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. 我真的希望你的意思是使用的最旧版本是VS 2005(.Net 2.0),它也可以使用这种方法进行定位 - 如果你真的使用的是VS 2003(目标是.Net 1.1) - 你运气不好, msbuild当时不存在。 But the dinosaurs did! 但是恐龙做到了!

You can target a different .NET framework from Visual Studio 2010 or from msbuild. 您可以从Visual Studio 2010或msbuild定位不同的.NET框架。 A build project can be setup to target .NET 2.0, .NET 3.5, and .NET 4. 可以将构建项目设置为针对.NET 2.0,.NET 3.5和.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. 除非.NET 4版本正在添加其他功能,否则没有理由不仅仅针对.NET 2并构建单个部署,因为这可以在没有问题的情况下从.NET 3.5和.NET 4项目中使用。

I would recommend installing Visual Studio 2010, as this will get you the version of msbuild that can target all 3 frameworks. 我建议安装Visual Studio 2010,因为这将为您提供可以针对所有3个框架的msbuild版本。

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+. 不幸的是,如果您的目标是.NET 1.1(2003),则需要单独构建,而较新版本的Visual Studio仅支持.NET 2.0+。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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