Search code examples
c#visual-studiomsbuildpublishdevenv

how to know publish full command when I click publish in visual studio


enter image description here

I know when I Click 'Rebuild Solution'. it is something like below.

[msbuild C:\Users\Micheal\source\repos\Calculator\Calculator.sln -t:publish]

enter image description here

enter image description here

But I do not know what exact publish command is.

I guess it is [msbuild C:\Users\dkssu\source\repos\Calculator\Calculator.sln -t:publish] But it is wrong. It just built and did not go further.

Here's my question. How to intercept commands when I click something in visual studio (2017/2019)


Solution

  • Actually, the command is different and you should note that -t:publish which only works for the publish of windows app projects.

    For asp net web projects, you should use PublishProfile file which is a publish guidance file.

    Use this:

    msbuild xxx\xxx.sln /p:DeployOnBuild=true /p:PublishProfile=xxx\xxx\PublishProfiles\FolderProfile.pubxml
    

    Although -t:publish can work on asp net web projects successfully, in fact, it does not play any function. After all, the command is for windows app publish.

    For windows app projects, it actually publish the project and it just doesn't show up in the default MSBuild log.

    You should additionally use -v:detailed command to check the detailed log.

    msbuild xxx\xxx.sln -t:publish -v:detailed
    

    And when you finish the command, you can check under the build output folder(bin\xxx), it actually there.

    enter image description here