Enrich Silen
Enrich Silen

Reputation: 13

Is it possible to use dotnet core console app as library

I tried to search if one can use .net core console application as a library. I know that there is .net standard for that, but I'm curious because other languages support that.

Upvotes: 1

Views: 1642

Answers (2)

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 117301

Libraries and applications are two different things.

A class library defines types and methods that are called by an application. A class library that targets the .NET Standard 2.0 allows your library to be called by any .NET implementation that supports that version of the .NET Standard.

A console application, in the context of C#, is an application that takes input and displays output at a command line console with access to three basic data streams: standard input, standard output and standard error. ... It is the simplest form of a C# program and is typically invoked from the command prompt.

I am not exactly sure what it is you are trying to achieve here. However try this lets say you have two console applications app 1 and app 2. Lets say app 2 has some objects you would like to use in app one. You could reference app two in app one and then you will have access to them.

Ideally though if you had an object that would be used by two different applications you would be creating a class library containing that object and then reference it from both applications.

Also .net core doesn't compile to an exe everything is a dll however you are dotnet run would not work on a library project.

Upvotes: 0

You can directly create a dll with netCore as Target

Upvotes: 1

Related Questions