This blog talks about how to change a created class library with a Console application in .net core. First, open a class library project in Visual Studio.
Step 1
- Right-click on the project from inside Visual Studio.
- Then click the properties option.
Step 2
- Change Class library selection to Console Application in Application > General > Output type.
- Then, save the changes and build the project.
Step 3
- Create a Program.cs file inside the project and add a Main(string[] args) inside a Program Class.
- Then, add a required function inside and execute a Console application.
The above-mentioned step is one way to handle this case. One more way is there to change a created class library with the Console application from the .csproj file.
- Edit the file .csproj <PropertyGroup><OutputType>Library</OutputType></PropertyGroup> Change "Library" to "Exe" to make it a console application.
- Save the .csproj file and close it.
- Then, add the Main function inside Program.cs and build the project.
.csproj
<PropertyGroup>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<OutputType>Exe</OutputType>
</PropertyGroup>