- .NET Core - Migrations
- Restoring and Building & MSBuild
- .NET Core - MSBuild & project.json
- .NET Core - SDK
- Managed Extensibility Framework
- .NET Core - Testing Library
- Running Tests in Visual Studio
- .NET Core - Create a Testing Project
- .NET Core - PCL Troubleshooting
- Creating a Xamarin.Forms Project
- Sharing .NET Core Libraries
- Adding References to Library
- .NET Core - Portable Class Library
- Create .NET Standard Library
- Windows Runtime & Extension SDKs
- .NET Core - Metapackage
- .NET Core - MSBuild
- Create UWP App with .NET Core
- .NET Core - Package References
- .NET Core - Project Files
- .NET Core - Modularity
- .NET Core - Code Execution
- .NET Core - Garbage Collection
- .NET Core - Numerics
- .NET Core - Getting Started
- .NET Core - Environment Setup
- .NET Core - Prerequisites
- .NET Core - Overview
- .NET Core - Home
.NET Core Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
.NET Core - Project Files
In this chapter, we will discuss .NET Core project files and how you can add existing files in your project.
Let us understand a simple example in which we have some files which are already created; we have to add these files in our FirstApp project.
Here is the implementation of the Student.cs file
using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace FirstApp { pubpc class Student { pubpc int ID { get; set; } pubpc string LastName { get; set; } pubpc string FirstMidName { get; set; } pubpc DateTime EnrollmentDate { get; set; } } }
Here is the implementation of the Course.cs file.
using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace FirstApp { pubpc class Course { pubpc int CourseID { get; set; } pubpc string Title { get; set; } pubpc int Credits { get; set; } } }
Let us now save these three files in your disk and the source folder of your project.
Now if you are famipar with .NET and this one was a traditional .NET framework console apppcation, it is important to understand how to add these files in your project in Visual Studio.
You first need to drag the files to the solution explorer to copy them in your project folder, because your project needs reference to these files.
One of the benefits of .NET Core is the approach taken with the project file (project.json); we can just drop files into the root of our project and then these will be automatically included in our project.
We don’t have to manually reference files pke we did in the past for traditional .NET Framework apppcation in Visual Studio.
Let us now open the root of your project.
Let us now copy all of the three files into the root of your project.
You can now see all the files copied to the root folder.
Let us now go to Visual Studio; you will receive the following dialog box.
Cpck Yes to All to reload your project.
You will now that files are automatically included in your project.
Advertisements