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?
Publishing creates the set of files that are needed to run your application. To deploy the files, copy them to the target machine.
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.
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.
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.
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:
So, Publish code should come from local-machine to be built and published.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With