Visual Studio For Mac Tutorials

Visual Studio for Mac provides a full-featured Integrated Development Environment (IDE) for developing.NET Core applications. This topic walks you through building a.NET Core solution that includes a reusable library and unit testing. This tutorial shows you how to create an application that.

Now that we have Visual Studio Code installed on our Mac, and have access to the Pis home directory (where we save our scripts) we can start to edit our code! Simply drag a file from the Raspberry Pi network share into Visual Studio Code. At the core of effective application development is a thorough knowledge of Visual Studio Mac. In this course, Visual Studio for Mac, you will learn how to work with VS Mac to produce enterprise-quality software.

Customize your IDE, learn the basics, and start building your first app within minutes.

Watch: Setting up your IDE

Find out the differences in Visual Studio for Mac when managing NuGet packages and working with source control. Come join us for a tour of this fully-featured IDE that will help every Mac developer create mobile and cloud applications. We started with a solid foundation for mobile development using Xamarin.

Watch: Tips & Tricks

Watch: Opening a project from Source

Install only the tool and component bundles you need for development in Visual Studio

ASP.NET & web development

Build web applications using ASP.NET Core, ASP.NET (.NET Framework), HTML/JavaScript, and Containers including Docker support

Description

Maximize your productivity developing .NET web applications using ASP.NET Core, standards-based technologies like HTML, and JavaScript.

Development applications

– Website using Razor Pages in ASP.NET Core
– Web API with ASP.NET Core MVC
– Real-time web apps with ASP.NET Core SignalR

Components

– .NET Framework 4.x development tools
– .NET Core 2.1 development tools
– ASP.NET and web development tools
– .NET profiling tools
– Container development tools
– Cloud tools for web development
– IntelliSense, code navigation, and refactoring for C#, Visual Basic, and F#

Learn more about ASP.NET & web development

Azure

Azure SDKs, tools, and projects for developing cloud apps, creating resources, and building Containers including Docker support

Description

Easily build, test, deploy, and manage scalable apps and services on the Microsoft cloud. Install to view resources in Cloud Explorer, create resources using Azure Manage tools, build applications for Azure Web and Cloud Services, and perform big data operations using Azure Datalake tools.

Development applications

– Publish an ASP.NET Core app to Azure in the IDE
– Test performance of a cloud service
– Debug a published Azure cloud service

Components

– Azure development prerequisites
– .NET Framework 4.x development tools
– .NET Core 2.1 development tools
– ASP.NET and web development tools
– Container development tools

Learn more about Azure

Python

Editing, debugging, interactive development, and source control for Python

Description

Support for building Python web applications using familiar frameworks including Django and Flask, and Data Science applications with built-in Conda and IPython support.

Development applications

– Python applications
– Django web apps
– Flask web apps

Components

Visual Studio Tutorial For Beginners

– Support for CPython, virtualenv, venv, and conda environments
– Rich editing, IntelliSense, and code comprehension
– Interactive (REPL) environment window
– Support for Python in open folder workspaces
– Project and item templates to simplify new project creating process
– Profiling and unit testing tools
– Manage Conda environments using Miniconda
– Live Share

Learn more about Python

Node.js development

Build fast and scalable applications using Node.js, a server-side JavaScript runtime environment

Description

Easily build Node.js applications using web frameworks like Express and front-end frameworks like React.

Development applications

– Node.js app with Express
– Node.js app with React
– Publish Node.js app to Azure cloud

Visual studio for mac xamarin tutorial

Components

Mac

– Project templates
– IntelliCode
– npm integration
– Interactive (REPL) environment window
– Local and remote advanced debugging
– Profiling tools to track performance
– Unit testing support
– TypeScript integration

Learn more about Node.js

.NET desktop development

Build WPF, Windows Forms, and console applications using C#, Visual Basic, and F#

Description

Create Windows-based applications by using Windows Presentation Foundation or by using Windows Forms. Also create web applications using the .NET Framework, and client applications for computers or devices that you make available through the Microsoft Store.

Development applications

– Windows Presentation Foundation (WPF)
– Windows Forms

Components

– .NET desktop development tools
– .NET Framework 4.x development tools
– .NET profiling tools
– C# and Visual Basic language support
– Entity Framework 6 tools
– IntelliTrace
– Just-In-Time debugger
– Live Unit Testing
– Live Share

Learn more about .NET desktop development

Desktop development with C++

Build modern C++ apps for Windows using the tools of your choice, including MSVC, Clang, CMake, or MS Build

Description

C++ desktop apps run in a console or in a window. Take advantage of the powerful MSVC compiler and libraries toolset or bring your own build tools to do the job.

Development applications

– Traditional Windows Desktop applications using C++
– Windows console applications using C++

Components

– MSVC x64/x86 build tools
– Visual C++ core desktop features
– C++ profiling tools
– Windows 10 SDK
– C++ CMake tools for Windows
– Test adapter for Google Test
– Test adapter for Boost.Test
– IntelliTrace
– Just-In-Time debugger
– Live Share

Learn more about Desktop development with C++

UWP development

Create applications for the Universal Windows Platform with C#, VB, or optionally C++

Description

Build applications that target Windows Desktop, Xbox, HoloLens, SurfaceHub, and even Windows 10 IoT.

Development applications

– Universal Windows Platform (UWP)

Components

– Blend for Visual Studio
– .NET Native and .NET Standard
– NuGet package manager
– Universal Windows Platform tools
– Windows 10 SDK

Learn more about UWP development

Mobile development with .NET

Build cross-platform applications for iOS, Android, or Windows using Xamarin

Description

Build fully-native iOS, Android, and Universal Windows Platform apps using C# and XAML. Xamarin gives you full access to platform APIs and features using a single language and allows you to have a shared codebase with other .NET platforms.

Development applications

– Build cross-platform apps using Xamarin.Forms
– Access native features with the Xamarin.Essentials API

Components

– Xamarin
– .NET Framework4.x development tools
– C# and Visual Basic language support
– Android SDK setup

Learn more about Mobile development with .NET

Mobile development with C++

Build cross-platform C++ apps for iOS or Android

Development applications

– Android Native App
– Import an XCode Project
– OpenGL ES application on Android and iOS

Components

– Visual Studio C++ core features
– Android SDK setup
– Android NDK
– Apache Ant
– C++ Android development tools

Learn more about Mobile development with C++

Game development with Unity

Create 2D and 3D games with Unity, a powerful cross-platform development environment

Description

Create games and interactive content and publish to 21 platforms, including all mobile platforms, WebGL, Mac, PC and Linux desktop, web or consoles.

Development applications

Develop Unity games with a premium debugging experience

Components

– Visual Studio Tools for Unity
– C# and Visual Basic

Learn more about Game development with Unity

Game development with C++

Use the full power of C++ to build professional games powered by DirectX, Unreal, or Cocos2d

Description

Use the full power of C++ to build professional games for Windows, Xbox, and other consoles powered by DirectX, Unreal Engine, or Cocos2d.

Development applications

– Xbox live apps
– UWP apps on HoloLens
– Marble Maze

Components

– MSVC x64/x86 build tools
– Visual Studio C++ core features
– Windows Universal C Runtime
– C++ profiling tools
– Windows 10 SDK
– IntelliTrace

Learn more about Game development with C++

Data storage & processing

Connect, develop, and test data solutions using SQL Server, Azure Data Lake, Hadoop, or Azure ML

Description

The Data workload enables you to develop across a wide range of relational and big data assets. It provides you the tools to develop queries against databases, data warehouses and data lakes, whether on-premises or in Azure. It provides support for SQL, U-SQL, and Hive.

Development applications

– Use SQL Server Data Tools to design, deploy, and mantain databases
– Develop U-SQL scripts by using Azure Data Lake Tools
– Run Hive queries with Hadoop on Azure HDInsight

Components

– SQL Server Data Tools
– Azure Data Lake and Stream Analytics Tools
– .NET Framework 4.x development tools

Learn more about Data storage & processing

Data science & analytical applications

Languages and tooling for creating data science applications, including Python and F#

Description

Use R and Python for wide range of scenarios such as data acquisition, cleaning, model training, deployment, and plotting. Use F#, a powerful functional-first .NET language, for a wide variety of data processing tasks.

Development applications

– Create visual data plots with R
– Work with the R interactive (REPL) window
– Create machine learning models using R and Microsoft ML Server

Components

– R and Microsoft R Client language support & runtime distributions
– Python and Anaconda language support & runtime distributions
– F# with the .NET framework language support & runtime distributions

Learn more about Data science & analytical applications

Visual Studio extension development

Create add-ons and extensions for Visual Studio, including new commands, code analyzers, and tool windows

Description

Add the SDKs and tools you need to create new commands, code analyzers, tool windows, and language services using C#. Then, share your extension with the community in the Visual Studio Marketplace.

Development applications

– Extensions for Visual Studio IDE
– Software development kit development

Components

– Visual Studio SDK
– Visual Studio extension development prerequisites
– .NET profiling tools
– IntelliTrace

Learn more about Visual Studio extension development

Office/SharePoint

Create Office and SharePoint add-ins, SharePoint solutions, and VSTO add-ins using C#, VB, and JavaScript

Description

Visual Studio 2017 For Mac

Take advantage of various project templates to extend Office and SharePoint. Easily build, debug, and publish your add-ins and solutions from Visual Studio.

Visual Studio For Mac Xamarin Forms Tutorial

Development applications

– Office add-ins
– VSTO add-ins
– SharePoint add-ins
– SharePoint solutions

Components

– Office Developer Tools for Visual Studio
– .NET Framework 4.5 targeting pack
– .NET Framework 4.x development tools
– Developer Analytics tools

Visual Studio Installer Projects Tutorial

Learn more about Office/SharePoint

Linux development with C++

Create and debug applications running in a Linux environment or Windows Subsystem for Linux (WSL)

Description

Build and run code on a remote machine or Windows Subsystem for Linux and browse, edit, and debug from within Visual Studio. Use CMake to target multiple platforms from the comfort of a single IDE.

Development applications

– Get Started

Components

– Visual Studio C++ core features
– Windows Universal C Runtime
– Visual C++ for Linux Development
– Visual C++ tools for CMake and Linux

Learn more about Linux development with C++

.NET Core cross-platform development

Build cross-platform applications using .NET Core, ASP.NET Core, HTML/JavaScript, and Containers including Docker support

Description

.NET Core is an open source, general-purpose development platform maintained by Microsoft and the .NET community on GitHub. It’s cross-platform (supporting Windows, macOS, and Linux), and can be used to build device, cloud, and IoT applications.

Development applications

– Complete .NET Core solution on Windows
– Docker images for .NET Core applications
– C# console application using .NET Core

Components

– .NET Core 2.x development tools
– .NET Framework 4.x development tools
– ASP.NET and web development tools prerequisites
– Cloud tools for web development
– .NET profiling tools
– IntelliTrace
– Live Unit Testing
– Live Share Learn more about .NET Core cross-platform development

Free, fully-featured IDE for students, open-source and individual
developers

Professional developer tools, services, and subscription benefits for small
teams

End-to-end solution to meet demanding quality and scale needs of teams of all
sizes

-->

Visual Studio for Mac provides a full-featured Integrated Development Environment (IDE) for developing .NET Core applications. This topic walks you through building a .NET Core solution that includes a reusable library and unit testing.

This tutorial shows you how to create an application that accepts a search word and a string of text from the user, counts the number of times the search word appears in the string using a method in a class library, and returns the result to the user. The solution also includes unit testing for the class library as an introduction to unit testing concepts. If you prefer to proceed through the tutorial with a complete sample, download the sample solution. For download instructions, see Samples and Tutorials.

Note

Your feedback is highly valued. There are two ways you can provide feedback to the development team on Visual Studio for Mac:

  • In Visual Studio for Mac, select Help > Report a Problem from the menu or Report a Problem from the Welcome screen, which opens a window for filing a bug report. You can track your feedback in the Developer Community portal.
  • To make a suggestion, select Help > Provide a Suggestion from the menu or Provide a Suggestion from the Welcome screen, which takes you to the Visual Studio for Mac Developer Community webpage.

Prerequisites

  • OpenSSL (if running .NET Core 1.1): See the Prerequisites for .NET Core on Mac topic.

For more information on prerequisites, see the Prerequisites for .NET Core on Mac. For the full system requirements of Visual Studio 2017 for Mac, see Visual Studio 2017 for Mac Product Family System Requirements.

Building a library

  1. On the Welcome screen, select New Project. In the New Project dialog under the .NET Core node, select the .NET Standard Library template. This creates a .NET Standard library that targets .NET Core as well as any other .NET implementation that supports version 2.0 of the .NET Standard. Select Next.

  2. Name the project 'TextUtils' (a short name for 'Text Utilities') and the solution 'WordCounter'. Leave Create a project directory within the solution directory checked. Select Create.

  3. In the Solution sidebar, expand the TextUtils node to reveal the class file provided by the template, Class1.cs. Right-click the file, select Rename from the context menu, and rename the file to WordCount.cs. Open the file and replace the contents with the following code:

  4. Save the file by using any of three different methods: use the keyboard shortcut +s, select File > Save from the menu, or right-click on the file's tab and select Save from the contextual menu. The following image shows the IDE window:

  5. Select Errors in the margin at the bottom of the IDE window to open the Errors panel. Select the Build Output button.

  6. Select Build > Build All from the menu.

    The solution builds. The build output panel shows that the build is successful.

Creating a test project

Unit tests provide automated software testing during your development and publishing. The testing framework that you use in this tutorial is xUnit (version 2.2.0 or later), which is installed automatically when the xUnit test project is added to the solution in the following steps:

  1. In the Solution sidebar, right-click the WordCounter solution and select Add > Add New Project.

  2. In the New Project dialog, select Tests from the .NET Core node. Select the xUnit Test Project followed by Next.

  3. Name the new project 'TestLibrary' and select Create.

  4. In order for the test library to work with the WordCount class, add a reference to the TextUtils project. In the Solution sidebar, right-click Dependencies under TestLibrary. Select Edit References from the context menu.

  5. In the Edit References dialog, select the TextUtils project on the Projects tab. Select OK.

  6. In the TestLibrary project, rename the UnitTest1.cs file to TextUtilsTests.cs.

  7. Open the file and replace the code with the following:

    The following image shows the IDE with the unit test code in place. Pay attention to the Assert.NotEqual statement.

    It's important to make a new test fail once to confirm its testing logic is correct. The method passes in the name 'Jack' (uppercase) and a string with 'Jack' and 'jack' (uppercase and lowercase). If the GetWordCount method is working properly, it returns a count of two instances of the search word. In order to fail this test on purpose, you first implement the test asserting that two instances of the search word 'Jack' aren't returned by the GetWordCount method. Continue to the next step to fail the test on purpose.

  8. Open the Unit Tests panel on the right side of the screen.

  9. Click the Dock icon to keep the panel open.

  10. Click the Run All button.

    The test fails, which is the correct result. The test method asserts that two instances of the inputString, 'Jack,' aren't returned from the string 'Jack jack' provided to the GetWordCount method. Since word casing was factored out in the GetWordCount method, two instances are returned. The assertion that 2 is not equal to 2 fails. This is the correct outcome, and the logic of our test is good.

  11. Modify the IgnoreCasing test method by changing Assert.NotEqual to Assert.Equal. Save the file by using the keyboard shortcut +s, File > Save from the menu, or right-clicking on the file's tab and selecting Save from the context menu.

    You expect that the searchWord 'Jack' returns two instances with inputString 'Jack jack' passed into GetWordCount. Run the test again by clicking the Run Tests button in the Unit Tests panel or the Rerun Tests button in the Test Results panel at the bottom of the screen. The test passes. There are two instances of 'Jack' in the string 'Jack jack' (ignoring casing), and the test assertion is true.

  12. Testing individual return values with a Fact is only the beginning of what you can do with unit testing. Another powerful technique allows you to test several values at once using a Theory. Add the following method to your TextUtils_GetWordCountShould class. You have two methods in the class after you add this method:

    The CountInstancesCorrectly checks that the GetWordCount method counts correctly. The InlineData provides a count, a search word, and an input string to check. The test method runs once for each line of data. Note once again that you're asserting a failure first by using Assert.NotEqual, even when you know that the counts in the data are correct and that the values match the counts returned by the GetWordCount method. Performing the step of failing the test on purpose might seem like a waste of time at first, but checking the logic of the test by failing it first is an important check on the logic of your tests. When you come across a test method that passes when you expect it to fail, you've found a bug in the logic of the test. It's worth the effort to take this step every time you create a test method.

  13. Save the file and run the tests again. The casing test passes but the three count tests fail. This is exactly what you expect to happen.

  14. Modify the CountInstancesCorrectly test method by changing Assert.NotEqual to Assert.Equal. Save the file. Run the tests again. All tests pass.

Adding a console app

  1. In the Solution sidebar, right-click the WordCounter solution. Add a new Console Application project by selecting the template from the .NET Core > App templates. Select Next. Name the project WordCounterApp. Select Create to create the project in the solution.

  2. In the Solutions sidebar, right-click the Dependencies node of the new WordCounterApp project. In the Edit References dialog, check TextUtils and select OK.

  3. Open the Program.cs file. Replace the code with the following:

  4. To run the app in a console window instead of the IDE, right-click the WordCounterApp project, select Options, and open the Default node under Configurations. Check the box for Run on external console. Leave the Pause console output option checked. This setting causes the app to spawn in a console window so that you can type input for the Console.ReadLine statements. If you leave the app to run in the IDE, you can only see the output of Console.WriteLine statements. Console.ReadLine statements do not work in the IDE's Application Output panel.

  5. Because the current version of Visual Studio for Mac cannot run the tests when the solution is run, you run the console app directly. Right-click on the WordCounterApp project and select Run item from the context menu. If you attempt to run the app with the Play button, the test runner and app fail to run. For more information on the status of the work on this issue, see xunit/xamarinstudio.xunit (#60). When you run the app, provide values for the search word and input string at the prompts in the console window. The app indicates the number of times the search word appears in the string.

  6. The last feature to explore is debugging with Visual Studio for Mac. Set a breakpoint on the Console.WriteLine statement: Select in the left margin of line 23, and you see a red circle appear next to the line of code. Alternatively, select anywhere on the line of code and select Run > Toggle Breakpoint from the menu.

  7. Right-click the WordCounterApp project. Select Start Debugging item from the context menu. When the app runs, enter the search word 'cat' and 'The dog chased the cat, but the cat escaped.' for the string to search. When the Console.WriteLine statement is reached, program execution halts before the statement is executed. In the Locals tab, you can see the searchWord, inputString, wordCount, and pluralChar values.

  8. In the Immediate pane, type 'wordCount = 999;' and press Enter. This assigns a nonsense value of 999 to the wordCount variable showing that you can replace variable values while debugging.

  9. In the toolbar, click the continue arrow. Look at the output in the console window. It reports the incorrect value of 999 that you set when you were debugging the app.

See also