Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does "Publish" in Visual Studio Work?

I am wondering how does Publish in Visual Studio work, the question is: Does the Publish in VS gets the code in the control-version to be built and published or does it get the code in local-machine to be built and published?

like image 363
Alan Nunes Avatar asked Oct 24 '18 17:10

Alan Nunes


People also ask

What does publish in Visual Studio do?

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 the difference between build and publish in Visual Studio?

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.

How do you publish a VS project?

To publish from Visual Studio, do the following: Change the solution configuration from Debug to Release on the toolbar to build a Release (rather than a Debug) version of your app. Right-click on the project (not the solution) in Solution Explorer and select Publish. In the Publish tab, select Publish.

What does .NET publish do?

dotnet publish compiles the application, reads through its dependencies specified in the project file, and publishes the resulting set of files to a directory. The output includes the following assets: Intermediate Language (IL) code in an assembly with a dll extension.


1 Answers

How does Publish in Visual Studio Work?

In simple terms, Publishing creates the set of files that are needed to run your application, and you can deploy the files by copying them to a target machine.

See How Web Publishing In Visual Studio Works for some more details.

Now, we need to figure out the question "Does the Publish in VS gets the code in the control-version to be built and published or does it get the code in local-machine to be built and published?".

To figure out the question, we need to change the "MSBuild project build output verbosity" to "Detailed". Do this by Tools -> Options...->Projects and Solutions->Build and Run. Set the MSBuild project build output verbosity level to Detailed. Then publish our project and check the log on the Output window, you will find Visual Studio copy the files from obj folder instead of the source code in the project file when you publishing project:

enter image description here

So, Publish code should come from local-machine to be built and published.

like image 140
Leo Liu-MSFT Avatar answered Oct 01 '22 07:10

Leo Liu-MSFT