Friday, September 26, 2025

Setup .NET modules support multiple framework

Environment requirement

  • Visual Studio 2019/2022 (with .NET SDK)
  • dotnet CLI (dotnet --version)
  • Access to your private feed, e.g. nuget.local
  • Your API key (e.g. nugetfeed)

Enable multi-framework (multi-targeting) at project configuration file(.csproj)

Visual Studio’s GUI only lets you pick one framework. To target multiple, edit the project file.
  1. In Solution Explorer → right-click the project → Edit Project File.
  2. Replace <TargetFramework> with <TargetFrameworks> (semicolon-separated).
For exmple

 <Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
     <TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
  

Fill nuget package metadata in Visual Studio

  1. Right-click project → Properties → Package tab.
  2. Fill:
    • Package ID: Geo.OpenDataExtender
    • Version: e.g., 1.0.0
    • Authors, Company, Description, Repository URL, License (if applicable)
For exmple



After filled

1. Open windows console at the main project file. Then input commend to package module.
dotnet pack -c Release
The result will like this


2. Push the module to nuget server.
ddotnet nuget push bin\Release\module.version.nupkg --source "https://nuget.geo.local/nuget" --api-key geo.developer --skip-duplicate
For exmple
dotnet nuget push bin\Release\Geo.OpenDataExtender.1.0.0.nupkg --source "https://nuget.local" --api-key nugetfeed --skip-duplicate

Finally

Choose any project and manage nuget packages. Check whether the module has been uploaded successfully.

No comments:

Post a Comment