Search code examples
c#nugetpaket

How do I compile a NuGet project from the command line?


I want to compile a C# project with NuGet dependencies without using Visual Studio (too heavy to download again). How could I do that?

With a normal Rust project I just need to run either cargo build or cargo rustc, for example, so I wonder how I could do it with a C#-NuGet-based solution (using paket).

To add more context, paket is downloading dependencies fine, but I don't know how to build my project yet. I've Mono installed, so I've nuget already available here.


Solution

  • You basically use MSBuild which Visual Studio uses behind the scene to build your application.

    Take a look at the documentation here. You can download it as a separate tool on your host machine and provide a path to your solution and run build. Here are the various build commands.

    Same goes to NuGet as well. You can download NuGet command line tool from here. Create a basic PowerShell script where you install/update package that your solution uses and then use the MSBuild tool to run your build.