Skip to end of metadata
Go to start of metadata

Step by step guide for automatic deployment of nopCommerce with git on azure

 

0) Your own git-repository
You need your own repository, you cannot just build nop. It's designed to be used with "publish" function in VS2013 as default.
I use bitbucket myself and keep that in sync with official repository.


1) Setup git on azure

Tutorial: https://azure.microsoft.com/da-dk/documentation/articles/web-sites-publish-source-control/
There's a great video here: http://channel9.msdn.com/Shows/Azure-Friday/What-is-Kudu-Azure-Web-Sites-Deployment-with-David-Ebbo

2) Prepare for local deploy

When you ensured that the automatic build works, we are ready to customize our deployment scripts. This is needed because the default automatic build only builds nop.web projects.
The problem with this is that it does not build the admin website, and none of the plugins are build. You cannot refer to the plugins as it would create circular references.

So now we need to get the custom build working, these are the install steps (also mentionen other places)

2.1 - Install NodeJs: https://nodejs.org
2.2 - Install Azure CLI: https://azure.microsoft.com/en-us/documentation/articles/xplat-cli-install/

3) Get nuget to work at command line level.

The default behavior of the KUDO script is to check for Nuget packages.

3.1 To get access to the Nuget.exe file you could either download from here: https://docs.nuget.org/consume/command-line-reference

You can also "Enable automatic restore of nuget packages" in you VS2013, and it will be added to your project automatically.

3.2 - Ensure that Nuget is in the path. Copy the nuget.exe file to preferred location (I use c:/Program Files/Nuget/Nuget.exe). Add it to path environment variable.

3.3 - Confirm that Nuget is in your path by starting cmd.exe and write nuget. you should see the command options.

4) Generate deployment scripts locally

4.1 - Open the "Microsoft Azure Command Prompt"

4.2 - Navigate to the src folder of your project as you normally would in a shell window

4.3 - Execute the azure script generator (found this nice tutorial: http://blog.amitapple.com/post/38418009331/azurewebsitecustomdeploymentpart2/#.VWyO3qikLjQ)

So you would write something like:

azure site deploymentscript --aspWAP Presentation\Nop.Web\Nop.Web.csproj -s NopCommerce.sln

4.4 - Verify that it has generated 2 files (in your local repository root):
.deployment
deploy.cmd

5 - Run generated script

5.1 - You must keep the .deployment and deploy.cmd file to the root of git repository

5.2 - Edit the deploy.cmd as the %DEPLOYMENT_SOURCE% variable contain the root of the git repository. So I would add %DEPLOYMENT_SOURCE%\src\Presentation\Nop.Web\Nop.Web.csproj instead of %DEPLOYMENT_SOURCE%\Presentation\Nop.Web\Nop.Web.csproj.
All paths in the deployment section must be corrected.

5.3 - Run deploy.cmd to see if the default deploy script works locally. It should create an \artifact folder just outside of your git repository.

6 - Customize the deployment script

So now we are at the final part :). This is where all that work pays off :). We want to alter the following piece:


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Deployment
:: ----------

echo Handling .NET Web Application deployment.

:: 1. Restore NuGet packages
IF /I "NopCommerce.sln" NEQ "" (
call :ExecuteCmd nuget restore "%DEPLOYMENT_SOURCE%\NopCommerce.sln"
IF !ERRORLEVEL! NEQ 0 goto error
)

:: 2. Build to the temporary path
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
call :ExecuteCmd "%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\Presentation\Nop.Web\Nop.Web.csproj" /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="%DEPLOYMENT_TEMP%";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release /p:SolutionDir="%DEPLOYMENT_SOURCE%\.\\" %SCM_BUILD_ARGS%
) ELSE (
call :ExecuteCmd "%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\Presentation\Nop.Web\Nop.Web.csproj" /nologo /verbosity:m /t:Build /p:AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release /p:SolutionDir="%DEPLOYMENT_SOURCE%\.\\" %SCM_BUILD_ARGS%
)

IF !ERRORLEVEL! NEQ 0 goto error

:: 3. KuduSync
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f "%DEPLOYMENT_TEMP%" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd"
IF !ERRORLEVEL! NEQ 0 goto error
)

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


So between no ::1 and ::2 that's where we are gonna place our commands for building plugins.

An example for the first plugin would be:

:: 1.01 Build plugin customer roles to temporary path
call :ExecuteCmd "%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\src\Plugins\Nop.Plugin.DiscountRules.CustomerRoles\Nop.Plugin.DiscountRules.CustomerRoles.csproj" /nologo /verbosity:m /t:Build /p:AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release /p:SolutionDir="%DEPLOYMENT_SOURCE%\.\\" %SCM_BUILD_ARGS%


Now the plugin is build when you run the deploy scripts :)

  • No labels