To start working with .NET Core, you need to install the SDK (Software Development Kit). Visit the official .NET download page and download the version suitable for your operating system.
After installation, verify that .NET Core is installed correctly by opening a terminal or command prompt and typing:
dotnet --version
This command will display the installed version of .NET Core SDK.
Use the command line to create a new .NET Core application. Navigate to your preferred directory and run the following command:
dotnet new console -n MyFirstApp
This will create a new console application named "MyFirstApp" with the required files and folder structure.
To test your application, navigate to the project directory and run the following command:
dotnet run
You should see the default "Hello, World!" message displayed in the terminal.
For better productivity, consider using an Integrated Development Environment (IDE). Popular options include:
Install the required plugins/extensions for .NET Core to enable IntelliSense, debugging, and other features.
To add additional libraries or dependencies to your project, use the dotnet add package
command. For example:
dotnet add package Newtonsoft.Json
This will add the Newtonsoft.Json library to your project, which you can use for JSON handling.
To prepare your application for deployment, build and publish it using the following commands:
dotnet build
dotnet publish -c Release -o ./publish
This will generate the compiled application in the ./publish
directory, ready to
deploy.