Back to results for “Project Structure”
.NET › .NET CLI, SDK & Project Structure (csproj)

How do project references (<ProjectReference>) differ from package references, and how do they affect build order?

Advanced

Answer

A <ProjectReference> points to another project's .csproj file within the same solution/repository, letting MSBuild automatically determine build order (dependencies built first) and always use the latest local source rather than a published NuGet package. This is preferred during active co-development of related projects, while PackageReference is used for external or independently versioned/released dependencies.
<ItemGroup>
  <ProjectReference Include="..\MyLib\MyLib.csproj" />
</ItemGroup>

<!-- MSBuild automatically builds MyLib first, then this project -->
Real-world example A solution with an API project and a shared Models class library uses a ProjectReference so any change to Models is immediately reflected in the API build without needing to publish and consume an internal NuGet package.

Common follow-ups: When should an internal library be published as a NuGet package instead of referenced directly?;How does circular project reference detection work?