Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The difference between build and publish in VS?

I am a little confused about the difference between build and publish in the visual studio.

What is the difference between building a program and publishing a program?

like image 866
user3594762 Avatar asked Dec 05 '14 16:12

user3594762


People also ask

What does it mean to publish in Visual Studio?

Publishing creates the set of files that are needed to run your application. To deploy the files, copy them to the target machine.

What is difference between build and deploy?

Deploy should mean take all of my artifacts and either copy them to a server, or execute them on a server. It should truly be a simple process. Build means, process all of my code/artifacts and prepare them for deployment. Meaning compile, generate code, package, etc.

What is the difference between deploying and publishing an application?

Deployment: It is a process of deploying the pre compiled dll's to the IIS server. Publish: It is a process of creating precompiled dll's. Web Hosting: It is similar to the process of deployment of a website. Deployment: It is a process of deploying the pre compiled dll's to the IIS server.


2 Answers

Build compiles the source code into a (hopefully) runnable application. Publish takes the results of the build, along with any needed third-party libraries and puts it somewhere for other people to run it. It may also make some changes to make the app runnable in the destination, depending on the framework and type of app (e.g. a console app may just copy files, while a web app may set up the configs based on the destination).

Your confusion may come from the fact that Publish will also build the application if it thinks it needs to (e.g. if there are source code changes).

like image 35
D Stanley Avatar answered Sep 17 '22 14:09

D Stanley


There are some significant differences between Build and Publish targeting .NET Framework application vs .NET Core applications:

Building .NET Framework applications will generate the same files as Publish. It will create all the dependencies as binaries including external dependencies (NuGet packages, for instance). So the product of dotnet build is ready to be transferred to another machine to run.

Building .NET Core applications, if the project has third-party dependencies, such as libraries from NuGet, they're resolved from the NuGet cache and aren't available with the project's built output. Therefore the product of dotnet build isn't ready to be transferred to another machine to run. You need to run Publish to get all 3rd party dependencies as binaries in output folder.

like image 163
OlegI Avatar answered Sep 19 '22 14:09

OlegI