If you don't have a device to deploy to, you'll need to setup an Android emulator or use a device. If you've already done this, you can skip this step.
If this if your first time building a Xamarin application, you'll need to create a new Android Emulator. You'll see 'Android Emulator' in the debug menu. Click it to start the creation process.
- .NET Core gives us the dotnet command line tools for us to build and run.net core apps without any IDE. Download and follow the installation steps for.NET Core in MAC here. Visual Studio Code. Visual Studio Code is a lightweight, yet powerful code editor which runs on MAC, Linux and Windows.
- May 19, 2020 Modern App Patterns. Part of the vision for one.NET is providing developer choice in the areas of personal preferences so you can be most productive using.NET. This manifests in which IDE you use whether Visual Studio 2019, Visual Studio for Mac, or even Visual Studio Code.NET.
This brings up a UAC prompt to be accepted and then the emulator creation process. The options are automatically populated for a base emulator. If required, change any options and then select Create.
At this point, you may be prompted to agree to the license agreement for the Android emulator. Read through and select Accept to continue the process. This will download the emulator images and finalize the creation of the emulator for use in Visual Studio.
Using dotnet publish to get the app ready for Mac Go ahead and type dotnet publish on the command prompt and then type tree to look at your directory listing as shown below: C. ├───bin │ └───Debug │ └───netcoreapp1.0 │ └───publish ├───obj │ └───Debug │ └───netcoreapp1.0.
Once the emulator has been created, you'll see a button that says Start. Click it.
You may receive prompt to enable Windows Hypervisor Platform. Follow the documentation to enable this feature for optimal performance.
The Android emulator will launch. Wait for it to fully finish starting and you'll see it displayed in the Visual Studio debug menu.
Your Android emulator has now been created and is ready to use. Next time you run Visual Studio, the emulator will appear directly in the debug target window and will start when you select it. If you ran into any issues or have performance issues with the emulator, read through the full setup documentation.
-->Create Dotnet App On Mac Computer
In this tutorial, you create a simple utility library that contains a single string-handling method. You implement it as an extension method so that you can call it as if it were a member of the String class.
Uninstall Dotnet Mac
A class library defines types and methods that are called by an application. A class library that targets .NET Standard 2.0 allows your library to be called by any .NET implementation that supports that version of .NET Standard. When you finish your class library, you can distribute it as a third-party component or as a bundled component with one or more applications.
Prerequisites
- Visual Studio Code with the C# extension installed. For information about how to install extensions on Visual Studio Code, see VS Code Extension Marketplace.
- The .NET Core 3.1 SDK or later
Create a solution
Start by creating a blank solution to put the class library project in. A solution serves as a container for one or more projects. You'll add additional, related projects to the same solution.
Start Visual Studio Code.
Select File > Open Folder (Open... on macOS) from the main menu
In the Open Folder dialog, create a ClassLibraryProjects folder and click Select Folder (Open on macOS).
Open the Terminal in Visual Studio Code by selecting View > Terminal from the main menu.
The Terminal opens with the command prompt in the ClassLibraryProjects folder.
In the Terminal, enter the following command:
The terminal output looks like the following example:
Create a class library project
Add a new .NET Standard class library project named 'StringLibrary' to the solution.
Dotnet Command Not Found Mac
In the terminal, run the following command to create the library project:
The terminal output looks like the following example:
Run the following command to add the library project to the solution:
The terminal output looks like the following example:
Check to make sure that the library targets the correct version of .NET Standard. In Explorer, open StringLibrary/StringLibrary.csproj.
The
TargetFramework
element shows that the project targets .NET Standard 2.0.Open Class1.cs and replace the code with the following code.
The class library,
UtilityLibraries.StringLibrary
, contains a method namedStartsWithUpper
. This method returns a Boolean value that indicates whether the current string instance begins with an uppercase character. The Unicode standard distinguishes uppercase characters from lowercase characters. The Char.IsUpper(Char) method returnstrue
if a character is uppercase.Save the file.
Run the following command to build the solution and verify that the project compiles without error.
The terminal output looks like the following example:
Add a console app to the solution
Add a console application that uses the class library. The app will prompt the user to enter a string and report whether the string begins with an uppercase character.
In the terminal, run the following command to create the console app project:
The terminal output looks like the following example:
Run the following command to add the console app project to the solution:
The terminal output looks like the following example:
Open ShowCase/Program.cs and replace all of the code with the following code.
The code uses the
row
variable to maintain a count of the number of rows of data written to the console window. Whenever it's greater than or equal to 25, the code clears the console window and displays a message to the user.The program prompts the user to enter a string. It indicates whether the string starts with an uppercase character. If the user presses the Enter key without entering a string, the application ends, and the console window closes.
Save your changes.

Add a project reference
Initially, the new console app project doesn't have access to the class library. To allow it to call methods in the class library, create a project reference to the class library project.
Run Dotnet App From Console
Run the following command:
The terminal output looks like the following example:
Dotnet New Console App
Run the app
Run the following command in the terminal:
Try out the program by entering strings and pressing Enter, then press Enter to exit.
The terminal output looks like the following example:
Additional resources
- .NET Standard versions and the platforms they support.
Next steps
Dotnet Create Console App
In this tutorial, you created a solution, added a library project, and added a console app project that uses the library. In the next tutorial, you add a unit test project to the solution.