Welcome to Shaun Luttin's public notebook. It contains rough, practical notes. The guiding idea is that, despite what marketing tells us, there are no experts at anything. Sharing our half-baked ideas helps everyone. We're all just muddling thru. Find out more about our work at bigfont.ca.

deploy.cmd - Build to the temporary path.

Tags: kudu, git-deploy

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:

  1. The default deployment passes msbuild the /t:pipelinePreDeployCopyAllFilesToOneFolder option. While I haven't found official documentation, I assume this means that msbuild puts the build results into a temporary folder as an intermediate step before running Kudu Sync.
  2. 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.

  1. call :ExecuteCmd    Run the subroutine at the the ExecuteCmd label, passing it all of the following as parameters.
  2. "%MSBUILDPATH%"   Specify the path to the msbuild executable.
  3. "%DEPLOYMENTSOURCE%\MyWebApp\MyWebApp.csproj"   Specify the location of our csproj file, which contains the targets that msbuild will run.
  4. /nologo   Don't output the banner or copyright to the command window.
  5. /verbosity:m   Only output minimal information in the build log.
  6. /t:Build   Instruct msbuild to run the Build target. A target is a group of tasks; we can instruct msbuild to run one or more groups of tasks or targets.
  7. /t:pipelinePreDeployCopyAllFilesToOneFolder   Instruct msbuild also to run this particular, poorly documented build task, that we explained above in this blog post.
  8. /p:   Pass msbuild some more properties.
    1. _PackageTempDir="%DEPLOYMENTTEMP%";   Specify the directory to which msbuild should save build results before it uses KuduSync to copy them to the destination directory.
    2. AutoParameterizationWebConfigConnectionStrings=false;   Don't tokenize the connection string.
    3. Configuration=Release    Build the release (as opposed to the debug) configuration.
  9. /p:SolutionDir="%DEPLOYMENTSOURCE%.\"   Pass the directory that contains our sln file.
  10. %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.

  1. call :ExecuteCmd "%MSBUILDPATH%"   
  2. %DEPLOYMENTSOURCE%\MyWebApp\MyWebApp.csproj"
  3. /nologo
  4. /verbosity:m
  5. /t:Build
  6. --- this instruction is missing from the in place deployment ---
  7. /p:
    1. --- this instruction is also missing from the in place deployment ---
    2. AutoParameterizationWebConfigConnectionStrings=false;
    3. Configuration=Release
  8. /p:SolutionDir="%DEPLOYMENTSOURCE%.\"
  9. %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

https://msdn.microsoft.com/en-us/library/ms171462.aspx

http://blogs.msdn.com/b/webdev/archive/2010/11/10/asp-net-web-application-publish-package-tokenizing-parameters.aspx