Skip to main content

Installation

This guide will help you install NetMediate and its companion packages in your .NET application.

Prerequisites

  • .NET 10.0, .NET Standard 2.0, or .NET Standard 2.1 compatible runtime
  • Visual Studio 2022+, Visual Studio Code, or JetBrains Rider
  • .NET CLI or NuGet Package Manager

Core Package Installation

dotnet add package NetMediate.Core
dotnet add package NetMediate.SourceGeneration
Why this release improves setup

Use NetMediate.Core in shared/contracts projects and NetMediate.SourceGeneration in the startup/application project. The generator package injects NetMediate and GenDI.SourceGenerator automatically via buildTransitive.

After running the command, your .csproj will have PackageReference entries for NetMediate.Core and NetMediate.SourceGeneration. For library projects, optionally add PrivateAssets="all" to the generator package to avoid transitive flow:

<ItemGroup>
<PackageReference Include="NetMediate.Core" Version="*" />
<PackageReference Include="NetMediate.SourceGeneration" Version="x.x.x.x">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>contentfiles; compile; runtime</PrivateAssets>
</PackageReference>

</ItemGroup>

Using Package Manager Console

Install-Package NetMediate.Core
Install-Package NetMediate.SourceGeneration

After running the command, your .csproj will have PackageReference entries for NetMediate.Core and NetMediate.SourceGeneration. See the note on PrivateAssets in the .NET CLI section above if you are building a library.

Using PackageReference

Add the following to your .csproj file:

<ItemGroup>
<PackageReference Include="NetMediate.Core" Version="*" />
<PackageReference Include="NetMediate.SourceGeneration" Version="x.x.x.x">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>contentfiles; compile; runtime</PrivateAssets>
</PackageReference>
</ItemGroup>
Library projects: PrivateAssets

NetMediate.SourceGeneration should use the explicit analyzer-style metadata below:

<PackageReference Include="NetMediate.SourceGeneration" Version="x.x.x.x">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>contentfiles; compile; runtime</PrivateAssets>
</PackageReference>

NetMediate.SourceGeneration still adds NetMediate and GenDI.SourceGenerator for the direct project.

Source Generation

NetMediate.SourceGeneration is the package you install directly in the startup/application project. Its buildTransitive file adds the required NetMediate runtime and GenDI.SourceGenerator automatically.

Optional Packages

Moq Testing Utilities

Provides testing helpers for unit tests:

dotnet add package NetMediate.Moq

Version Compatibility

PackageMinimum .NET VersionSupported TFMs
NetMediate.Core.NET Standard 2.0netstandard2.0
NetMediate.NET Standard 2.0net10.0, netstandard2.0, netstandard2.1
NetMediate.SourceGeneration.NET Standard 2.0netstandard2.0 (analyzer)
NetMediate.Moq.NET Standard 2.0net10.0, netstandard2.0, netstandard2.1

Verifying Installation

After installation, verify that NetMediate is available in your project:

using NetMediate;
using Microsoft.Extensions.DependencyInjection;

var services = new ServiceCollection();
services.AddNetMediate(); // Generated by the NetMediate.SourceGeneration package

If AddNetMediate() is not recognized, make sure:

  1. Your startup project references NetMediate.SourceGeneration
  2. You've rebuilt your project
  3. Your IDE has refreshed its IntelliSense cache

Next Steps

Now that you have NetMediate installed, proceed to: