Search code examples
visual-studiomsbuildpublish

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?


Solution

  • 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.