C# 如何选择.NET版本来编译项目?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1108359/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to choose .NET version to compile project?
提问by joycollector
I have VS2005. How can I compile my project under specific version of .NET? I have installed 1.0, 2.0, 3.0 & 3.5. Tnx in advance.
我有VS2005。如何在特定版本的 .NET 下编译我的项目?我已经安装了 1.0、2.0、3.0 和 3.5。提前Tnx。
采纳答案by Ant
You can't I'm afraid. VS2005 only works with .NET framework 2.0. You'll need the appropriate versions of Visual Studio to work with other versions:
你不能,我害怕。VS2005 仅适用于 .NET framework 2.0。您需要适当版本的 Visual Studio 才能与其他版本一起使用:
- 1.0: Visual Studio .NET
- 1.1: Visual Studio .NET 2003
- 2.0: Visual Studio 2005 / 2008
- 3.0 / 3.5: Visual Studio 2008
- 4.0: Visual Studio 2010
- 1.0:Visual Studio .NET
- 1.1:Visual Studio .NET 2003
- 2.0:Visual Studio 2005 / 2008
- 3.0 / 3.5:Visual Studio 2008
- 4.0:Visual Studio 2010
jmservera points out that some 3.0 libraries are compatible with Visual Studio 2005. For example WCF is compatible, while LINQ isn't. Some of these require additional downloads, for example to use Windows Workflow Foundation comfortably in Visual Studio 2005, you need to install this extension.
jmservera 指出一些 3.0 库与 Visual Studio 2005 兼容。例如 WCF 兼容,而 LINQ 不兼容。其中一些需要额外下载,例如要在 Visual Studio 2005 中舒适地使用 Windows Workflow Foundation,您需要安装此扩展。
回答by Kirtan
This is just for your information: If you are using VS version greater than or eqaul to 2008, you can do this by right clicking the project you want to build, click Properties
, and select the Application
tab (if not already selected). Change the value in the Target Framework
dropdown list.
这仅供参考:如果您使用的 VS 版本大于或等于 2008,您可以通过右键单击要构建的项目,单击Properties
,然后选择Application
选项卡(如果尚未选择)来执行此操作。更改Target Framework
下拉列表中的值。
(source: scottgu.com)
(来源:scottgu.com)
回答by jmservera
VS2005 has no support for 1.0,1.1 and 3.5, you only would be able to compile from 2.0 up to 3.0. 3.0 are only new libraries added to 2.0 so you only have to add the references.
VS2005 不支持 1.0、1.1 和 3.5,您只能从 2.0 编译到 3.0。3.0 只是添加到 2.0 的新库,因此您只需添加引用。
回答by AutomatedTester
When you compile a project it will look at the project Target Framework in the project properties. You can only compile .net items against certain versions of VS
编译项目时,它会在项目属性中查看项目目标框架。您只能针对某些版本的 VS 编译 .net 项目
回答by yeyeyerman
I think you can do that if you use the SharpDevelop IDE, which is free, and really similar to Visual Studio. http://www.icsharpcode.net/OpenSource/SD
我认为如果您使用 SharpDevelop IDE,它是免费的,并且与 Visual Studio 非常相似,那么您就可以做到这一点。http://www.icsharpcode.net/OpenSource/SD
回答by rockeye
Visual 2008 allow you to choose a specific version of the framework in the project properties.
Visual 2008 允许您在项目属性中选择特定版本的框架。
In Visual 2005, by default, projects use v2.0 but you can build 3.5 projects to using templates (WPF application, WCF, ....)
在 Visual 2005 中,默认情况下,项目使用 v2.0,但您可以构建 3.5 项目以使用模板(WPF 应用程序、WCF 等)
回答by AdaTheDev
I believe it is possible with MSBuild:
我相信 MSBuild 是可能的:
http://social.msdn.microsoft.com/forums/en-US/msbuild/thread/6043542c-6946-488c-b5f4-960eaed7a9f4/
http://social.msdn.microsoft.com/forums/en-US/msbuild/thread/6043542c-6946-488c-b5f4-960eaed7a9f4/
On a side note, I use VS 2008 and when I view the Properties for a project, I get the option to build for 3 different target frameworks: .NET 2.0, 3.0 and 3.5
附带说明一下,我使用 VS 2008,当我查看项目的属性时,我可以选择为 3 个不同的目标框架构建:.NET 2.0、3.0 和 3.5