1

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • you want to compile a C# project, or you want to create a nuget package file based on the already-compiled DLL? It's not very clear, from your description. Either, way you can search for each of these tasks online very easily and find Microsoft documentation as well as examples and tutorials provided by others. What did you research? What did you try? What problem are you facing which you would like help with? We're not here to do your googling for you. – ADyson Aug 02 '18 at 22:23
  • you're using nuget or paket? If you want to compile c# project with nuget packages via command line from e.g Visual Studio Code which is lightweight you can just write in terminal dotnet buiild – komluk Aug 02 '18 at 23:03
  • @ADyson I've clarified a bit more. But... We're not here to do your googling for you. : I've googled something like `'Compile C# project using Mono or nuget'`, but it just redirected me to a Microsoft guide to nuget. Then I didn't know anything about MSBuild as the answer @Kalagen provided me. –  Aug 03 '18 at 01:34
  • @komluk `paket` is a helper for `nuget`, so I'm using both as well! P.S.: VSCode doesn't come with `dotnet`. –  Aug 03 '18 at 01:35
  • you can't use nuget to compile a project, so that might be why google was confused about that. Nuget is for creating package files which can include compiled (or un-compiled) C# code, or any other content for that matter. It's not a build engine. – ADyson Aug 03 '18 at 08:19

1 Answers1

1

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
na-98
  • 909
  • 8
  • 16
  • 1
    So, in Mono, MSBuild is called [XBuild](https://www.mono-project.com/docs/tools+libraries/tools/xbuild/). Well, thank you for the words. –  Aug 03 '18 at 01:10