On your computer, the shop builds with the packages you added one day with dotnet add package. A server starts with .NET and none of your packages. It reads the project file, shop.csproj, and dotnet restore downloads every package listed there.
The project file is XML. <Project Sdk='Microsoft.NET.Sdk.Web'> says the shop is a web app, so ASP.NET Core and its web server, Kestrel, come with .NET. <TargetFramework> names the .NET version. Each package is a PackageReference, and its exact Version pins it: restore downloads exactly that version, on every machine, not whatever is newest on the day it runs. Parts of .NET, like System.Text.Json, stay out of the file: they aren't packages restore downloads. Here is the file of another project, a small bot that sends a newsletter:
<Project Sdk='Microsoft.NET.Sdk'>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include='MailKit' Version='4.8.0' />
</ItemGroup>
</Project>
In this lesson the file's text is a C# list of strings, csproj, one string per line of the file. XML takes single quotes around a value, so the strings need no escaped double quotes. The check reads the file the way dotnet restore would and prints:
shop.csproj:
<Project Sdk='Microsoft.NET.Sdk.Web'>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include='Microsoft.Data.Sqlite' Version='8.0.11' />
</ItemGroup>
</Project>
dotnet restore:
Sdk Microsoft.NET.Sdk.Web: a web app, so ASP.NET Core and its web server, Kestrel, come with .NET; nothing to download
TargetFramework net8.0: builds the shop for .NET 8, on every machine
Microsoft.Data.Sqlite 8.0.11: this exact version, on every machine
The shop needs ASP.NET Core (Program.cs calls WebApplication.CreateBuilder): Microsoft.NET.Sdk.Web
The shop needs .NET 8 (the course builds and tests the shop on .NET 8): net8.0
The shop needs Microsoft.Data.Sqlite (Program.cs opens shop.db with it): pinned to 8.0.11
Your task: write the shop's project file: a <Project> with the web SDK Microsoft.NET.Sdk.Web, a PropertyGroup with the TargetFramework net8.0, and an ItemGroup with a PackageReference to Microsoft.Data.Sqlite, pinned to 8.0.11.
Assignment
Follow the Coding Tutorial to write csproj, the lines of the shop's shop.csproj: the SDK, the .NET version and one pinned package.
Hint
Each line of the file is a string with a comma after it. Every <Tag> needs its </Tag>, or closes itself with />, like the PackageReference.
Free plan: 30 tutor messages. PRO is unlimited.
