Nuget Build and Publish Scripts for Multiple Targets
Here’s a set of basic command line steps to run, to generate a nuget package for a library or an executable.
NOTE: These statements are for projects that target multiple runtimes. So, they can be simplified for a single runtime or single target framework.
For a Library
To build, package, and publish a library, a variant of these statements is needed:
// Build the library...
dotnet build "./NETCore_Common_NET6.csproj" -c DebugLinux --runtime linux-x64 --no-self-contained
dotnet build "./NETCore_Common_NET6.csproj" -c DebugWin --runtime win-x64 --no-self-contained
To create the nuget package file from built files...
D:\Programs\nuget\nuget.exe pack ./NETCore_Common_NET6.nuspec -IncludeReferencedProjects -symbols -SymbolPackageFormat snupkg -OutputDirectory bin -Verbosity detailed
To publish nuget package...
dotnet nuget push -s https://buildtools.ogsofttech.com:8079/v3/index.json "P:\Projects\NETCore SoftwareLibraries\NETCore SoftwareLibraries\NETCore_Common_NET6\bin\NETCore_Common_NET6.1.4.6.nupkg"
For an Application
To build an executable, these statements will build and publish the application binaries:
// Build the main assembly for windows and linux...
dotnet build "./NETCore_Common_NET6.csproj" -c DebugLinux --runtime linux-x64 --no-self-contained
dotnet build "./NETCore_Common_NET6.csproj" -c DebugWin --runtime win-x64 --no-self-contained
// Publish the main assembly for both Windows and Linux...
dotnet publish "./NETCore_Common_NET6.csproj" -c DebugWin -o bin/publish/debug/win-x64 /p:DefineConstants=Windows --runtime win-x64 --no-self-contained
dotnet publish "./NETCore_Common_NET6.csproj" -c DebugLinux -o bin/publish/debug/linux-x64 /p:DefineConstants=Linux --runtime linux-x64 --no-self-contained
No Comments