Microsoft Visual Studio的第一个版本于 1998 年发布。目前,最新版本名为 Visual Studio 2017,包含大量功能。自 1998 年发布以来,它已经走过了漫长的道路。好吧(Well),让我们快速深入了解初学者如何开始使用 VS。因此,首先,您需要决定是使用在线安装程序还是先将其离线。这出奇的复杂。由于软件包中存在Android Emulator(Android Emulator)和 iOS SDK等第三方组件, Microsoft无法像以前那样直接托管离线ISO映像,直到VS 2015为止。因此(Hence),有两种不同的方式来下载软件,具体取决于您是需要离线安装程序还是在线安装程序。让我们一个一个地浏览它们。
如何安装 Visual Studio
离线方法
获得正确的版本
首先(First),您需要确定您实际要下载的Microsoft Visual Studio版本。(Microsoft Visual Studio)然后,您将需要为该特定版本获取合适的 Web 安装程序。以下链接适用于您想要的VS 2017版本的 Web 安装程序。
- (Get)从此处(here.)获取Visual Studio Community 2017 。
- (Find)从此处(here.)查找Visual Studio Professional 2017 。
- (Download Visual Studio Enterprise 2017)从此处(here.)下载 Visual Studio Enterprise 2017 。
获取离线缓存的所有文件
这个区域有点棘手。在这里,您首先要判断需要下载哪些开发组件。.NET Web 和桌面开发包有一个单独的命令(是的!命令)。一个单独的用于 .NET Office 开发(Office Development)和相应的更多。
让我们开始了解每个组件。我在说这个;你不需要得到所有的组件。只获取那些对你很重要的东西。
首先,以管理员(Administrator)权限打开(Rights)命令提示符(Command Prompt)。
然后,导航(Navigate)到存储您刚刚下载的安装程序的位置。
现在,根据您的需要开始执行以下命令行指令。
- 对于.NET Web 和.NET 桌面(.NET Desktop)开发,运行以下命令:
vs_community.exe --layout c:\vs2017layout --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NetWeb --add Component.GitHub.VisualStudio --includeOptional --lang en-US
- 对于.NET Desktop and Office Development,运行这个:
vs_community.exe --layout c:\vs2017layout --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.Office --includeOptional --lang en-US
vs_community.exe --layout c:\vs2017layout --add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended --lang en-US
- 要获得完整的功能丰富的离线组件集合,请运行以下命令:
vs_community.exe --layout c:\vs2017layout --lang en-US
如果您不想使用英语作为软件的语言,只需将上述命令中的en-US换成 您想要的语言即可。
从下载的缓存安装 Visual Studio
万一您希望确保仅安装已下载的那些文件,您可以运行此命令行指令进行验证。
vs_community.exe --layout c:\vs2017layout --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NetWeb --add Component.GitHub.VisualStudio --includeOptional --lang en-US
现在,最后要从下载的文件中安装 VS,运行这个命令行指令。
c:\vs2017layout\vs_community.exe --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NetWeb --add Component.GitHub.VisualStudio --includeOptional
在线安装
要使用在线安装程序下载 Visual Studio,只需根据所需版本下载以下文件之一。
- (Get)从此处(here.)获取Visual Studio Community 2017 。
- (Find)从此处(here.)查找Visual Studio Professional 2017 。
- (Download Visual Studio Enterprise 2017)从此处(here.)下载 Visual Studio Enterprise 2017 。
只需运行您刚刚下载的文件。之后,您将看到与此类似的屏幕。
现在,单击继续(continue),现在您将看到此页面。
在此页面上,您必须选择需要下载的组件。选择它们并单击 安装。(Install.)
之后,您将看到 VS 正在下载并应用您选择的组件,如下面的屏幕截图所示。
在此之后,您只需插入您的设备,以防您使用的是笔记本电脑或Surface设备。之所以如此,是因为您不希望您的计算机在进行此安装时进入睡眠状态。当您的安装程序完成应用所有必需的组件时,您将看到此屏幕。
尤里卡!你的机器上安装了 Visual Studio 2017。您可以在“开始”菜单(Start Menu)中找到它,如下面的屏幕片段所示,或者将其作为桌面上的快捷方式找到。
现在,当您运行 Visual Studio时,它会要求您使用您的Microsoft 帐户登录(Microsoft Account)。如果您使用的是专业版(Professional)或企业(Enterprise)版,我建议您使用用于购买订阅的电子邮件登录。登录后,您将看到此 入门 (Get Started )页面。
首先,我们将了解VS 2017内部的工作方式。导航到 File> New > Project. 现在将弹出一个小窗口,如下面的屏幕片段所示。
仅作为初学者和一个简单的程序示例,在左侧面板中选择(Choose)Visual C# library,在组件列表中选择控制台应用程序。(Console App)现在,点击 确定。(OK.)
这将创建一个基于 C#控制台应用程序(Console App)的新项目并打开它。
现在,您可以开始在上面的代码段中标记的花括号之间编写代码。
在该代码块中编写此代码。(代码块是特定函数的两个大括号之间的区域。这里是Main 函数。)
Console.WriteLine("Welcome to TheWindowsClub.com!");
Console.ReadLine();
现在,您的代码应该看起来像这样:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Welcome to TheWindowsClub.com!");
Console.ReadLine();
}
}
}
按键盘上的F5 运行程序。现在,将弹出一个控制台窗口,显示输出为
Welcome to TheWindowsClub.com!
现在由于代码写成 Console.ReadLine(); 您必须按键盘上的任意键才能返回您的代码。
这是一个用 C# 编写的非常基本的程序,如果您想了解更多信息,我建议您查看我们的关于.NET Framework和.NET Core支持的语言(Languages)的教程。如果您想从官方视频中学习,Microsoft Virtual Academy ( MVA ) 将能够为您提供帮助。MVA甚至会帮助您直接获得Microsoft认证。
提示(TIP):要从MVA学习 C# ,我强烈建议您参考 Bob Tabor 的教程,该教程可在此处找到(found here)。
如果您还有任何疑问,请随时发表评论,我会尽我所能尽快解决。(If you have any further queries, feel free to comment them down, and I will try my best to address them as soon as possible.)
A beginner's guide on how to get started with Visual Studio
The first version of Microsoft Visual Studio was released in 1998. Currently, the latest offering is named Visual Studio 2017 and contains a ton of features. It has come a long way since it was released in 1998. Well, lets just quickly dive in on how a beginner can get started with VS. So, first of all, you will need to decide if you are gonna use an online installer or get it offline first. This is strangely complicated. Due to the presence of third-party components like Android Emulator and iOS SDK, etc. in the package, Microsoft cannot directly host the offline ISO images as it used to until VS 2015. Hence, there are two different ways to download the software depending upon if you want an offline or an online installer. Let us just go through both of them one by one.
How to install Visual Studio
Offline Method
Getting the right edition
First of all, you need to make sure what edition of Microsoft Visual Studio you actually want to download. Then, you will have to need to get the suitable web installer for that particular edition. The following links are for the web installer of your desired edition of VS 2017.
- Get Visual Studio Community 2017 from here.
- Find Visual Studio Professional 2017 from here.
- Download Visual Studio Enterprise 2017 from here.
Getting all the files for an offline cache
This area is slightly tricky. Here, you will have first to judge what development components you need to download. There is a separate command (yes! command) for .NET web and desktop development packages. A separate one for .NET Office Development and accordingly more.
Let us just get started for each component. I am saying this; you need not get all the components. Get just those that matter to you.
First, open Command Prompt with Administrator Rights.
Then, Navigate to the location where the installer that you just downloaded is stored.
Now, start executing the following command line instructions as per your need.
- For .NET web and .NET Desktop development, run this:
vs_community.exe --layout c:\vs2017layout --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NetWeb --add Component.GitHub.VisualStudio --includeOptional --lang en-US
- For .NET Desktop and Office Development, run this:
vs_community.exe --layout c:\vs2017layout --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.Office --includeOptional --lang en-US
- For C++ desktop development, run this:
vs_community.exe --layout c:\vs2017layout --add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended --lang en-US
- For the complete feature packed offline collection of components, run this:
vs_community.exe --layout c:\vs2017layout --lang en-US
If you want to not use English as the language for the software, just swap en-US in the commands above with your desired language.
Installing Visual Studio from the downloaded cache
Just in case you wish to ensure that you install only those files that you have downloaded, you can run this command line instruction to verify.
vs_community.exe --layout c:\vs2017layout --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NetWeb --add Component.GitHub.VisualStudio --includeOptional --lang en-US
Now, finally to install VS from the downloaded files, run this command line instruction.
c:\vs2017layout\vs_community.exe --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NetWeb --add Component.GitHub.VisualStudio --includeOptional
Online installation
To download Visual Studio with an online installer, just download one of the following files according to your desired edition.
- Get Visual Studio Community 2017 from here.
- Find Visual Studio Professional 2017 from here.
- Download Visual Studio Enterprise 2017 from here.
Just run the file that you just downloaded. After that, you will see a screen similar to this.
Now, click on continue and now you will see this page.
On this page, you will have to select the components that you need to download. Select them and click on Install.
After this, you will see VS downloading and applying components that you selected as shown in the screenshot below.
After this, you just have to plug in your device in case you are using a laptop or a Surface device. This is so because you don’t want your computer to go to sleep while this installation is taking place. And when your installer is done with applying all the required components, you will see this screen.
Eureka! You have Visual Studio 2017 installed on your machine. You can find it in the Start Menu as shown in the screen snippet below or else find it as a shortcut on your desktop.
Now, when you run Visual Studio, it will ask you to sign in with your Microsoft Account. If you are using Professional or Enterprise edition, I would recommend you to sign in with the email that you used to buy the subscription. After you are signed in, you will see this Get Started page.
First, we will see how things work inside VS 2017. Navigate to File> New > Project. A small window will pop up now which will resemble this as shown in the screen snippet below.
Just for starters and a simple program example, Choose the Visual C# library in the left panel and Console App in the list of components. And now, hit OK.
This will create a new project based on a C# Console App and open it.
Now, you can start writing your code in between those curly braces as marked in the snippet above.
Write this code in that code block. (A code block is a region between two curly brackets of a particular function. Here, the Main function.)
Console.WriteLine("Welcome to TheWindowsClub.com!");
Console.ReadLine();
Simply now your code should be looking something like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Welcome to TheWindowsClub.com!");
Console.ReadLine();
}
}
}
Hit F5 on your keyboard to run the program. Now, a console window will pop up showing you the output as
Welcome to TheWindowsClub.com!
Now due to the code is written as Console.ReadLine(); you will have to press any key on the keyboard to return to your code.
This was a very basic program written in C#, in case you would like to discover more, I would recommend you to check our Tutorials about Languages supported in .NET Framework and .NET Core. And in case you wish to learn from official videos, Microsoft Virtual Academy (MVA) will be able to help you. MVA will even help you certified by Microsoft directly.
TIP: To learn C# from MVA, I would highly recommend you to refer Bob Tabor’s tutorials which can be found here.
If you have any further queries, feel free to comment them down, and I will try my best to address them as soon as possible.