DEV Community

Swapnil Takalkar
Swapnil Takalkar

Posted on • Edited on

How to build solution, run tests, create package using .Net commands.

Ever wondered that how build is executed in the build pipeline? Or maybe how tests are run in the build pipeline?

Well, DevOps certainly knows that. But .Net developers usually build the solution from visual studio using the menu.

Sometimes there will be too many errors or a glitch but commands can help you to know exact errors and eliminate the glitch if any.
Also these commands will be useful to build a pipeline.

Let’s get into the topic.

Pre requisite:

  • .Net framework (.Net core or above recommended)
  • Powershell or Developers Command Prompt for VS

Open the powershell/Developers Command Prompt and go to the directory where solution is located.

1) dotnet clean - Cleans the solution by removing obj, bin folders where build related files are being stored.

Image description

2) dotnet restore - Restore all the dependencies such as NuGet packages from the repository.

Image description

3) dotnet build - Build the solution, which will be ready to run.

Image description

4) dotnet test - Runs the tests from all of the test projects.

Image description

5) dotnet pack - Packs the solution so that it can be uploaded as an artifact.

Image description

6) dotnet publish - Publish the solution. Creates required files that needs to run the application in the publish folder.

Image description

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay