Has anyone ever wondered about the difference between the build and publish functions in software development? As we know, both the build and publish are important steps in software development, especially when using Visual Studio for .NET applications. 

Let’s check the typical development lifecycle to determine later the differences between those actions.

Typical Development Lifecycle

The typical development cycle refers to the series of steps required to create an application.

Support Code Maze on Patreon to get rid of ads and get the best discounts on our products!
Become a patron at Patreon!

Let’s take a look at the essential steps we follow during development:

Illustrates a typical development lifecycle

Initially, in the Development stage, the actual coding of the software takes place using the programming languages and frameworks. In this phase, developers write code for front-end (UI) and back-end (server-side) functionality.

The Build stage is used to transform the source code into machine-readable code. This process involves looking for errors, warnings, and syntax problems, and creating executable files with their necessary dependencies.

In the Testing stage, we confirm that the application functions correctly and meets the actual requirements. It involves conducting tests, including unit tests and integration tests.

Finally, the Publish and Deployment stage is where we package our app and make it available for end users. This includes creating all necessary files, dependencies, and configuration settings, as well as configuring the application for the target environment. 

Let’s have a closer look at the Build and Publish steps.

What Is “Build” in Visual Studio

The Build is the step in the software development cycle that comes next after finishing the coding, which converts readable source code into executable software.

It begins by compiling the source code into machine-readable binaries, including libraries and application functions. The build process carefully checks the code for any warnings, syntax errors, or syntax issues to generate a software package ready for testing and iterative development.

The compiler converts code into Intermediate Language (IL) files with an .dll extension depending on project specifications. It might generate additional files like executables, debugging symbol files .pdb, .deps.json and .runtimeconfig.json files.

We can execute the build process either by the CLI command or through the Visual Studio toolbar.

Let’s first explore how to build using the CLI:

dotnet build

With the dotnet build command, we build the project or solution found in the current working directory.

For more details and options about the dotnet build CLI command, please check out the Microsoft documentation and for detailed instructions, you can have a look at our article Using the CLI to Build and Run .NET Applications.

Now, let’s look into Visual Studio:

Shows the Build option in Visual Studio

With a right click to open the context menu on our project or solution in the Solution Explorer of Visual Studio, we can identify the option to Build.

What Is “Publish” in Visual Studio

Now that we’ve built and tested the solution, how do we make it available to users?

Publish is where we prepare an application for distribution and delivery to end users. This step packages all necessary files and dependencies such as binaries, libraries, and configuration settings into a deployable format. Typically, publishing makes the application ready for the target environment by asset optimization, file compression, and file transfer configuration.

Once published, the application automatically creates and modifies dependencies, creates a ready-to-use directory structure, and configures itself for end-user installation.

We can publish a .NET application either by the CLI command or through the Visual Studio toolbar.

First, let’s explore how to publish using the CLI:

dotnet publish

With the dotnet publish command, we publish the project or solution found in the current working directory.

For more details and options about the dotnet publish CLI command, please check out the Microsoft documentation.

Now, let’s take a look at Visual Studio:

Shows the Publish option in Visual Studio

Again, with a right-click on the project or solution in the Solution Explorer, we find the option to publish via the selected item’s context menu.

If you want to know more about publishing an application, check out our article about Publishing an ASP.NET Core App to Azure App Service Using Visual Studio.

Differences Between Build and Publish

As we have already seen, the build and publish processes are two distinct entities that serve different purposes with specific results. The build process compiles the source code and generates the output in a bin folder. Then, the publish process retrieves this information from the bin folder and packages it into the executable, ready to be sent to the destination folder or target location.

The project’s target framework impacts the outcome of the build and publish process.

For projects with targeting versions earlier than .NET Core 3.0, the dependencies from NuGet are not copied to the output folder during the build process. They need to publish executable versions. But for projects targeting .NET Core 3.0 and above automatically include the dependencies in the build, reducing the need for additional pre-deployment steps.

When to Use Build And Publish

Now we understand the difference between Build and Publish, let us look at when and where to use these.

While developing on our local machine we use build it to compile codes and check syntax errors. It is essential for testing purposes or debugging within our local computer.

When we are ready to deploy our application to a hosting environment, we select publish. This will include all necessary dependencies to make the application self-contained and ready for execution on the target system. This becomes particularly important when distributing applications into environments that may not have .NET runtime easily accessible.


A clear understanding of the difference between build and publish is essential to the successful development and implementation of programs. Publish extends the process by packaging the application and its dependencies into a deployable format, while build focusing on assembling code into binaries. Using these correctly allows developers to effortlessly distribute their applications across multiple hosting locations and optimize their deployment pipeline.

Liked it? Take a second to support Code Maze on Patreon and get the ad free reading experience!
Become a patron at Patreon!