Introduction
This article demonstrates how to create console applications on Mac OS X (10.12.3), Ubuntu 14.04 and Windows 10 using .NET Core. This article gives the details of OS versions, Tools set and a demo. We will create a multiple project solution using Visual Studio Code, which contains two Console Applications and 4 Library Projects. We will learn how to add Project Reference and Package Reference. We will also see how to configure and execute two console applications within the same solution. Please refer to (Part 3) my previous article which creates multiple project solutions with single console application (.NET Core Console Applications On Mac OS X, Ubuntu 14.04 And Windows 10 - Part Three). Also please refer to Part 1 & 2 of the article to give the basics. The main use case is that development teams are working on the same code base with the same tool set, and the key is different Operating System.
The code tested on below Operating System Versions,
- Mac OS X (10.12.3)
- Ubuntu 14.04
- Windows 10
Tools Set
- .NET Core 1.0.4
- .NET Command Line Interface (cli) Tools
- Visual Studio Code (1.12.2)
- Git
Source Code Link.
Demo 1 - Multiple Projects [2 Console Application and 4 Library projects] using terminal, cli, and Visual Studio Code
- Introduction to the solution
This solution will contain 6 projects. - DataCore.csproj
This project contains the data model. This will be used to hold the metadata of the libraries (StringLibrary, ArrayLibrary). - CoreLibrary.csproj
This project contains two interfaces. IRunner and IProcessor. - ArrayLibrary.csproj
This project contains an ArrayDemo.cs class, which will accept an array and prints the array in reverse. - StringLibrary.csproj
This project contains two classes. PalindromicString.cs displays whether a given string is Palindrome or not. ToggleString.cs toggles each alphabet. - LogicPrograms.csproj
This is the console application project. It consumes both StringLibrary.csproj and ArrayLibrary.csproj. It will read the metadata from appsettings.json and executes the methods from each class using Metadata. It uses reflection. - StringPrograms.csproj
This is the console application project. It consumes only StringLibrary.csproj. It will read the metadata from appsettings.json and executes the methods from each class using Metadata. It uses reflection.
Please refer to the image to get a better picture.

Mac OS X (10.12.3)
Get the latest version of code from GitHub.
git pull

Create a Folder called MultiLibMultiApps. Copy and Paste the five (DataCore, CoreLibrary, ArrayLibrary, StringLibrary, LogicPrograms) Projects which we created in MultiLibraryApp. Please refer Part 3 of the article.


Open MultiLibMultiApps folder in Visual Studio. Your solution should look similar to the image below.

Select Program.cs inside LogicPrograms folder. Visual Studio Code will display a dialog box for creation .vscode folder with launch.json and tasks.json. Please select “Yes”.

Also change the console type inside launch.json to “integratedTerminal”, so that we will be able to input the data to the program.
- // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
- "console": "integratedTerminal",
- "stopAtEntry": false,
- "internalConsoleOptions": "openOnSessionStart"
- },

Execute the solution, it should work and invoke the methods from 3 three classes.

Within the integrated terminal execute the below mentioned commands to create new console application within existing solution.
mkdir StringPrograms
cd StringPrograms
dotnet new console
dotnet restore

Now we have two console applications. We have to instruct Visual Studio Code to execute which particular console application. For this we have to modify launch.json and tasks.json.
Launch.json
We should add Launch configuration for each application that should be executed. In the below code we have two configurations, one for LogicPrograms and another for StringPrograms. The “program” element should point to the binary of that console application which will be launched. In our case LogicPrograms.dll and StringPrograms.dll.
- {
- "name": ".NET Core Launch (LogicPrograms)",
- "type": "coreclr",
- "request": "launch",
- "preLaunchTask": "build",
- // If you have changed target frameworks, make sure to update the program path.
- "program": "${workspaceRoot}/LogicPrograms/bin/Debug/netcoreapp1.1/LogicPrograms.dll",
- "args": [],
- "cwd": "${workspaceRoot}/LogicPrograms",
- // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
- "console": "integratedTerminal",
- "stopAtEntry": false,
- "internalConsoleOptions": "openOnSessionStart"
- },
- {
- "name": ".NET Core Launch (StringPrograms)",
- "type": "coreclr",
- "request": "launch",
- "preLaunchTask": "build",
- // If you have changed target frameworks, make sure to update the program path.
- "program": "${workspaceRoot}/StringPrograms/bin/Debug/netcoreapp1.1/StringPrograms.dll",
- "args": [],
- "cwd": "${workspaceRoot}/StringPrograms",
- // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
- "console": "integratedTerminal",
- "stopAtEntry": false,
- "internalConsoleOptions": "openOnSessionStart"
- }
Once we navigate to debug mode, we will be able to see all the configuration items which was defined in the launch.json. In our case we have added two Launch configuration items for both console applications.

Note












Laxmidhar SahooPosted Apr 27, 2019, 12:37 AM
Fantastic DEscription thanks
Khaja MoizuddinPosted Jun 7, 2017, 11:50 AM
Great Collection of .Net Core Sir.