Durandal SPA在Build Deployment命令中使用Optimizer部署到Azure Web站点

时间:2013-06-12 20:02:15

标签: azure deployment durandal optimization

我运行Azure命令行工具以使用以下命令生成下面的脚本

C:\GameDev\DevPortal>azure site deploymentscript --aspWAP "DeveloperPortal\Devel
operPortal.csproj" -s "DeveloperPortal.sln"

脚本:

@echo off

:: ----------------------
:: KUDU Deployment Script
:: ----------------------

:: Prerequisites
:: -------------

:: Verify node.js installed
where node 2>nul >nul
IF %ERRORLEVEL% NEQ 0 (
  echo Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment.
  goto error
)

:: Setup
:: -----

setlocal enabledelayedexpansion

SET ARTIFACTS=%~dp0%artifacts

IF NOT DEFINED DEPLOYMENT_SOURCE (
  SET DEPLOYMENT_SOURCE=%~dp0%.
)

IF NOT DEFINED DEPLOYMENT_TARGET (
  SET DEPLOYMENT_TARGET=%ARTIFACTS%\wwwroot
)

IF NOT DEFINED NEXT_MANIFEST_PATH (
  SET NEXT_MANIFEST_PATH=%ARTIFACTS%\manifest

  IF NOT DEFINED PREVIOUS_MANIFEST_PATH (
    SET PREVIOUS_MANIFEST_PATH=%ARTIFACTS%\manifest
  )
)

IF NOT DEFINED KUDU_SYNC_CMD (
  :: Install kudu sync
  echo Installing Kudu Sync
  call npm install kudusync -g --silent
  IF !ERRORLEVEL! NEQ 0 goto error

  :: Locally just running "kuduSync" would also work
  SET KUDU_SYNC_CMD=node "%appdata%\npm\node_modules\kuduSync\bin\kuduSync"
)
IF NOT DEFINED DEPLOYMENT_TEMP (
  SET DEPLOYMENT_TEMP=%temp%\___deployTemp%random%
  SET CLEAN_LOCAL_DEPLOYMENT_TEMP=true
)

IF DEFINED CLEAN_LOCAL_DEPLOYMENT_TEMP (
  IF EXIST "%DEPLOYMENT_TEMP%" rd /s /q "%DEPLOYMENT_TEMP%"
  mkdir "%DEPLOYMENT_TEMP%"
)

IF NOT DEFINED MSBUILD_PATH (
  SET MSBUILD_PATH=%WINDIR%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
)

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

echo Handling .NET Web Application deployment.




:: 1. Build to the temporary path
%MSBUILD_PATH% "%DEPLOYMENT_SOURCE%\DeveloperPortal\DeveloperPortal.csproj" /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="%DEPLOYMENT_TEMP%";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release /p:SolutionDir="%DEPLOYMENT_SOURCE%\.\\" %SCM_BUILD_ARGS%
IF !ERRORLEVEL! NEQ 0 goto error

:: 2. Durandal Node js Optimize
echo Running Durandal Optimizer
%DEPLOYMENT_SOURCE%\DeveloperPortal\App\durandal\amd\optimizer --source %DEPLOYMENT_TEMP%\App\


:: 3. KuduSync
call %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




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

goto end

:error
echo An error has occurred during web site deployment.
call :exitSetErrorLevel
call :exitFromFunction 2>nul

:exitSetErrorLevel
exit /b 1

:exitFromFunction
()

:end
echo Finished successfully.

我在部署区域添加了第2步,它调用了优化器,我提供了源代码,因为我注意到如果我没有,我会在优化完成后找到一个js文件时出错。

一切运行正常,但Azure上的网站没有更新,没有任何更改通过,我查看日志,它有以下内容:

Command: deploy.cmd
Handling .NET Web Application deployment.
  All packages listed in packages.config are already installed.
  DeveloperPortal -> C:\DWASFiles\Sites\socialplay\VirtualDirectory0\site\repository\DeveloperPortal\bin\DeveloperPortal.dll
  Transformed Web.config using C:\DWASFiles\Sites\socialplay\VirtualDirectory0\site\repository\DeveloperPortal\Web.Release.config into obj\Release\TransformWebConfig\transformed\Web.config.
  Copying all files to temporary location below for package/publish:
  C:\DWASFiles\Sites\socialplay\Temp\8bdcc230-a749-42d9-9b04-dfb7f84a5bf1.
Running Durandal Optimizer
Using default base configuration.
Configuring for deploy with almond (custom).
{
  "name": "durandal/amd/almond-custom",
  "inlineText": true,
  "stubModules": [
    "durandal/amd/text"
  ],
  "paths": {
    "text": "durandal/amd/text"
  },
  "baseUrl": "C:\\DWASFiles\\Sites\\socialplay\\VirtualDirectory0\\site\\repository\\DeveloperPortal\\App\\",
  "mainConfigFile": "C:\\DWASFiles\\Sites\\socialplay\\VirtualDirectory0\\site\\repository\\DeveloperPortal\\App\\main.js",
  "include": [
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/main-built",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/main",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/content/text/GamesLocalization",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/content/text/InstantiatedItemsLocalization",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/content/text/itemWizardLocalization",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/content/text/r",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/durandal/app",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/durandal/composition",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/durandal/events",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/durandal/http",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/durandal/messageBox.html",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/durandal/messageBox",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/durandal/modalDialog",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/durandal/system",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/durandal/viewEngine",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/durandal/viewLocator",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/durandal/viewModel",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/durandal/viewModelBinder",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/durandal/widget",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/durandal/plugins/router",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/durandal/transitions/entrance",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/services/dataservice",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/services/logger",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/viewmodels/appdetails",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/viewmodels/baseitems",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/viewmodels/classes",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/viewmodels/documentation",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/viewmodels/games",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/viewmodels/home",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/viewmodels/items",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/viewmodels/itemstore",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/viewmodels/liveexample",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/viewmodels/loginRegister",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/viewmodels/sdk",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/viewmodels/shell",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/viewmodels/tutorials",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/viewmodels/Instantiated/instantiated",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/viewmodels/ItemCreationWizard/itemCreationWizard",
    "C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/viewmodels/WorldWizard/worldWizard",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/appdetails.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/baseitems.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/classes.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/devmenu.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/documentation.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/footer.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/games.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/home.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/HomeGuest.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/items.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/itemstore.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/liveexample.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/loginRegister.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/nav.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/sdk.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/shell.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/titleBar.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/tutorials.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/Instantiated/givePlayerItem.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/Instantiated/instantiated.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/Instantiated/playerSelect.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/Instantiated/playersItems.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/ItemCreationWizard/baseitembehaviours.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/ItemCreationWizard/baseitemimage.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/ItemCreationWizard/baseItemname.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/ItemCreationWizard/baseitemproperties.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/ItemCreationWizard/baseitemquality.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/ItemCreationWizard/baseitemunity3d.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/ItemCreationWizard/baseitemvariations.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/ItemCreationWizard/classbehaviours.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/ItemCreationWizard/classname.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/ItemCreationWizard/classproperties.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/ItemCreationWizard/classselect.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/ItemCreationWizard/generateditems.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/ItemCreationWizard/helppage.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/ItemCreationWizard/itemCreationWizard.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/WorldWizard/worldWizard.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/WorldWizard/worldWizard_App.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/WorldWizard/worldWizard_Currency.html",
    "text!C:/DWASFiles/Sites/socialplay/VirtualDirectory0/site/repository/DeveloperPortal/App/views/WorldWizard/worldWizard_World.html"
  ],
  "exclude": [],
  "keepBuildDir": true,
  "optimize": "uglify2",
  "out": "C:\\DWASFiles\\Sites\\socialplay\\VirtualDirectory0\\site\\repository\\DeveloperPortal\\App\\main-built.js",
  "pragmas": {
    "build": true
  },
  "wrap": true,
  "insertRequire": [
    "main"
  ]
}
Deleting old output file.
 Tracing dependencies for: durandal/amd/almond-custom
 KuduSync.NET from: 'C:\DWASFiles\Sites\socialplay\Temp\8bdcc230-a749-42d9-9b04-dfb7f84a5bf1' to: 'C:\DWASFiles\Sites\socialplay\VirtualDirectory0\site\wwwroot'
Copying file: 'Web.config'
Finished successfully.

似乎没问题,但看起来也好像,KuduSync可能会替换durandal生成的文件,所以我尝试在deploy.cmd的第2步中引用%DEPLOYMENT_TEMP%,

:: 2. Durandal Node js Optimize

echo Running Durandal Optimizer %DEPLOYMENT_SOURCE%\ DeveloperPortal \ App \ durandal \ amd \ optimizer --source%DEPLOYMENT_TEMP%\ App \

最终发生的事情是,main-built.js是空的,我的页面没有加载。

这就是我被困的地方

2 个答案:

答案 0 :(得分:1)

空的main-built.js表示optimizer运行r.js时出错。 我尝试使用node r.js -o app.build.js手动运行r.js.请在Durandal.js optimizer not working (empty main-built.js)

查看更多信息

答案 1 :(得分:0)

Durandal 2.0不再需要优化器了,升级到它时,我不再这一步了。