You would have to create a nuspec file to for the nuget package and use nuget.exe to pack the files. This article describes the steps.
How can I package a .NET Framework console App into a nuget?
I have a requirement where I need to package my console app developed with net472 into a nuget which can be easily run using cli command. I was able to find a resource dealing with this https://blog.maartenballiauw.be/post/2017/04/10/extending-dotnet-cli-with-custom-tools.html, however, this is working a expected for .NET Core but not for .NET Framework. Adding the mentioned changes to the property group in csproj file doesn't result in build failure but it is also not generating a nuget.
CSPROJ Changes:
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A46B7A20-4DB8-478D-88D3-031FC5403E3B}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>NugetBotPoc</RootNamespace>
<AssemblyName>NugetBotPoc</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<PackageId>Taskless.NugetBotPoc</PackageId>
<PackageVersion>1.0.0</PackageVersion>
<AssemblyName>dotnet-NugetBotPoc</AssemblyName>
<PackageType>DotnetCliTool</PackageType>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PackageId>Taskless.NugetBotPoc</PackageId>
<PackageVersion>1.0.0</PackageVersion>
<AssemblyName>dotnet-NugetBotPoc</AssemblyName>
<PackageType>DotnetCliTool</PackageType>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PackageId>Taskless.NugetBotPoc</PackageId>
<PackageVersion>1.0.0</PackageVersion>
<AssemblyName>dotnet-NugetBotPoc</AssemblyName>
<PackageType>DotnetCliTool</PackageType>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
</PropertyGroup>
It would be really great if I could get some help on this and even if this is possible with .NET Framework.
2 answers
Sort by: Most helpful
-
-
Sreeju Nair 11,606 Reputation points
2021-11-25T10:52:14.707+00:00 Basically Nuget is for distributing class libraries. I recommend you to use https://chocolatey.org/ to package your console application.
Refer: https://octopus.com/docs/runbooks/runbook-examples/routine/installing-software-chocolatey
Also you can achieve nuget distribution with the help of CLI. Refer the following post
https://stackoverflow.com/questions/48100600/best-practice-to-include-console-app-in-nuget