The difference between build and publish in VS?

2019-02-03 00:18发布

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?

3条回答
smile是对你的礼貌
2楼-- · 2019-02-03 00:29

Build compiles the source code into a (hopefully) runnable application. Publish takes that runnable application and puts it somewhere for other people to run it. 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).

查看更多
贪生不怕死
3楼-- · 2019-02-03 00:32

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(NuGets 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.

查看更多
欢心
4楼-- · 2019-02-03 00:41

Building and Publishing a project in VS are totally different things. The build process, invloves compiling your project's code and storing the binary result into DLLs. You can find them under \bin\debug\ folder or \bin\release\ folder under your project's root. That depends if you're building in Debug or Release mode. These DLLs store the application's binary data and can be referenced into other projects. The publishing process always comes after the build process. Let's suppose that you have a ASP.NET application. If you want to use your project, building your web application into DLLs will not be sufficiant, since you need to host your web application into a web server which will be IIS or ASP.NET development server. It invloves hosting your application to be accessed by client entities. Basically, you can publish web applications and web services.

查看更多
登录 后发表回答