deploy.cmd - Build to the temporary path.
What does the default Kudu deploy.cmd for ASP.NET Web Apps do at the
msbuild
stage of deployment?
First, Kudu will check whether we have set the
%IN_PLACE_DEPLOYMENT%
environmental variable to
1
. If we have not set it to
1
, Kudu will do the default deployment. Otherwise, Kudu will do an in place deployment.
From looking at the
if... else...
statement during the
msbuild
stage of deployment, the default deployment differs from an in place deployment build in two ways:
-
The default deployment passes
msbuildthe/t:pipelinePreDeployCopyAllFilesToOneFolderoption. While I haven't found official documentation, I assume this means thatmsbuildputs the build results into a temporary folder as an intermediate step before running Kudu Sync. -
The default deployment also specifies
PackageTempDir="%DEPLOYMENTTEMP%";as the directory that stores the build results before Kudu Sync copies them to the deployment directory.
In other words, the default deployment adds a step that the in place deployment does not have. It looks something like this:
- msbuild -> to -> Temp Directory -> KuduSync -> to Destination Directory
Here is a list of what the deploy.cmd file does at the
msbuild
stage. As mentioned above, it first checks whether were doing an in place deployment.
If
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
This is the default deployment.
-
call :ExecuteCmdRun the subroutine at the theExecuteCmdlabel, passing it all of the following as parameters. -
"%MSBUILDPATH%"Specify the path to themsbuildexecutable. -
"%DEPLOYMENTSOURCE%\MyWebApp\MyWebApp.csproj"Specify the location of ourcsprojfile, which contains the targets thatmsbuildwill run. -
/nologoDon't output the banner or copyright to the command window. -
/verbosity:mOnly output minimal information in the build log. -
/t:BuildInstructmsbuildto run theBuildtarget. A target is a group of tasks; we can instructmsbuildto run one or more groups of tasks or targets. -
/t:pipelinePreDeployCopyAllFilesToOneFolderInstructmsbuildalso to run this particular, poorly documented build task, that we explained above in this blog post. -
/p:Passmsbuildsome more properties.-
_PackageTempDir="%DEPLOYMENTTEMP%";Specify the directory to whichmsbuildshould save build results before it uses KuduSync to copy them to the destination directory. -
AutoParameterizationWebConfigConnectionStrings=false;Don't tokenize the connection string . -
Configuration=ReleaseBuild the release (as opposed to the debug) configuration.
-
/p:SolutionDir="%DEPLOYMENTSOURCE%.\"
Pass the directory that contains our
sln
file.
%SCMBUILD_ARGS%
Allow for us to use environmental variables to pass
msbuild
further options.
Else...
This is the in place deployment. Kudu will run almost the exact same
msbuild
command, but will leave out two options.
-
call :ExecuteCmd "%MSBUILDPATH%" -
%DEPLOYMENTSOURCE%\MyWebApp\MyWebApp.csproj" -
/nologo -
/verbosity:m -
/t:Build - --- this instruction is missing from the in place deployment ---
-
/p:- --- this instruction is also missing from the in place deployment ---
-
AutoParameterizationWebConfigConnectionStrings=false; -
Configuration=Release
/p:SolutionDir="%DEPLOYMENTSOURCE%.\"
%SCMBUILD_ARGS%
Follow Up Question
Why would we elect to do an in place deployment?
Resources
https://msdn.microsoft.com/en-us/library/ms164311.aspx
https://github.com/projectkudu/kudu/wiki/Deploying-inplace-and-without-repository
https://github.com/projectkudu
https://msdn.microsoft.com/en-us/library/ms164311.aspx