02.08.2020

Visual Studio For Mac Publish Console App

Visual Studio For Mac Publish Console App 3,6/5 6025 votes
-->

May 04, 2018  Hi, I created a C# console application which I want to publish and deploy to the production server. VS 2017 published the application to my destination folder with a setup.exe along with the Application Files folder on my development box. Inside the Application Files folder, it contains the. Hi Brandon, Welcome to the MSDN forum. Refer to your.

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.

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

  1. Visual Studio Code with the C# extension installed. For information about how to install extensions on Visual Studio Code, see VS Code Extension Marketplace.
  2. 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.

  1. Start Visual Studio Code.

  2. Select File > Open Folder (Open.. on macOS) from the main menu

  3. In the Open Folder dialog, create a ClassLibraryProjects folder and click Select Folder (Open on macOS).

  4. 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.

  5. 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.

  1. In the terminal, run the following command to create the library project:

    The terminal output looks like the following example:

  2. Run the following command to add the library project to the solution:

    Hp elite autofocus webcam mac software. The terminal output looks like the following example:

  3. 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.

  4. Open Class1.cs and replace the code with the following code.

    The class library, UtilityLibraries.StringLibrary, contains a method named StartsWithUpper. 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 returns true if a character is uppercase.

  5. Save the file.

  6. 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

Visual

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.

  1. In the terminal, run the following command to create the console app project:

    The terminal output looks like the following example:

  2. Run the following command to add the console app project to the solution:

    The terminal output looks like the following example:

  3. 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.

  4. Save your changes.

Visual Studio For Mac Os

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.

  1. Run the following command:

    The terminal output looks like the following example:

Run the app

  1. Run the following command in the terminal:

  2. Try out the program by entering strings and pressing Enter, then press Enter to exit.

    The terminal output looks like the following example:

Visual Studio For Mac Publish Console Application

Additional resources

  • .NET Standard versions and the platforms they support.

Next steps

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.