2016-02-16 196 views
5

我對Azure和Angular2完全陌生。Azure部署Angular 2項目時,Github連續部署失敗

的目的

安裝Azure的持續部署與GitHub上。

的問題

Azure是撿承諾對資源庫中的主要分支。所以這部分是好的。但是,由於構建錯誤,部署失敗。

這裏是部署詳情:

enter image description here

這裏是完整的日誌:

Command: "D:\home\site\deployments\tools\deploy.cmd" 
Handling .NET Web Application deployment. 
MSBuild auto-detection: using msbuild version '14.0' from 'D:\Program Files (x86)\MSBuild\14.0\bin'. 
All packages listed in packages.config are already installed. 
D:\home\site\repository\LearnJS\LearnJS.Web\app\app.component.ts(1,41): error TS2307: Build: Cannot find module 'angular2/core'. [D:\home\site\repository\LearnJS\LearnJS.Web\LearnJS.Web.csproj] 
D:\home\site\repository\LearnJS\LearnJS.Web\app\app.component.ts(2,46): error TS2307: Build: Cannot find module 'angular2/router'. [D:\home\site\repository\LearnJS\LearnJS.Web\LearnJS.Web.csproj] 
D:\home\site\repository\LearnJS\LearnJS.Web\app\crisis-form.component.ts(1,25): error TS2307: Build: Cannot find module 'angular2/core'. [D:\home\site\repository\LearnJS\LearnJS.Web\LearnJS.Web.csproj] 
D:\home\site\repository\LearnJS\LearnJS.Web\app\crisis-form.component.ts(2,22): error TS2307: Build: Cannot find module 'angular2/common'. [D:\home\site\repository\LearnJS\LearnJS.Web\LearnJS.Web.csproj] 
D:\home\site\repository\LearnJS\LearnJS.Web\app\crisis.component.ts(1,33): error TS2307: Build: Cannot find module 'angular2/core'. [D:\home\site\repository\LearnJS\LearnJS.Web\LearnJS.Web.csproj] 
D:\home\site\repository\LearnJS\LearnJS.Web\app\crisis.component.ts(2,30): error TS2307: Build: Cannot find module 'angular2/http'. [D:\home\site\repository\LearnJS\LearnJS.Web\LearnJS.Web.csproj] 
D:\home\site\repository\LearnJS\LearnJS.Web\app\crisis.service.ts(1,48): error TS2307: Build: Cannot find module 'angular2/core'. [D:\home\site\repository\LearnJS\LearnJS.Web\LearnJS.Web.csproj] 
D:\home\site\repository\LearnJS\LearnJS.Web\app\crisis.service.ts(2,55): error TS2307: Build: Cannot find module 'angular2/http'. [D:\home\site\repository\LearnJS\LearnJS.Web\LearnJS.Web.csproj] 
D:\home\site\repository\LearnJS\LearnJS.Web\app\crisis.service.ts(4,26): error TS2307: Build: Cannot find module 'rxjs/Observable'. [D:\home\site\repository\LearnJS\LearnJS.Web\LearnJS.Web.csproj] 
D:\home\site\repository\LearnJS\LearnJS.Web\app\crisis.service.ts(12,16): error TS2304: Build: Cannot find name 'Promise'. [D:\home\site\repository\LearnJS\LearnJS.Web\LearnJS.Web.csproj] 
D:\home\site\repository\LearnJS\LearnJS.Web\app\hero-form.component.ts(1,25): error TS2307: Build: Cannot find module 'angular2/core'. [D:\home\site\repository\LearnJS\LearnJS.Web\LearnJS.Web.csproj] 
D:\home\site\repository\LearnJS\LearnJS.Web\app\hero-form.component.ts(2,22): error TS2307: Build: Cannot find module 'angular2/common'. [D:\home\site\repository\LearnJS\LearnJS.Web\LearnJS.Web.csproj] 
D:\home\site\repository\LearnJS\LearnJS.Web\app\hero.component.ts(1,33): error TS2307: Build: Cannot find module 'angular2/core'. [D:\home\site\repository\LearnJS\LearnJS.Web\LearnJS.Web.csproj] 
D:\home\site\repository\LearnJS\LearnJS.Web\app\hero.component.ts(2,30): error TS2307: Build: Cannot find module 'angular2/http'. [D:\home\site\repository\LearnJS\LearnJS.Web\LearnJS.Web.csproj] 
D:\home\site\repository\LearnJS\LearnJS.Web\app\hero.service.ts(1,48): error TS2307: Build: Cannot find module 'angular2/core'. [D:\home\site\repository\LearnJS\LearnJS.Web\LearnJS.Web.csproj] 
D:\home\site\repository\LearnJS\LearnJS.Web\app\hero.service.ts(2,55): error TS2307: Build: Cannot find module 'angular2/http'. [D:\home\site\repository\LearnJS\LearnJS.Web\LearnJS.Web.csproj] 
D:\home\site\repository\LearnJS\LearnJS.Web\app\hero.service.ts(4,26): error TS2307: Build: Cannot find module 'rxjs/Observable'. [D:\home\site\repository\LearnJS\LearnJS.Web\LearnJS.Web.csproj] 
D:\home\site\repository\LearnJS\LearnJS.Web\app\hero.ts(1,18): error TS1148: Build: Cannot compile modules unless the '--module' flag is provided. [D:\home\site\repository\LearnJS\LearnJS.Web\LearnJS.Web.csproj] 
D:\home\site\repository\LearnJS\LearnJS.Web\app\main.ts(1,28): error TS2307: Build: Cannot find module 'angular2/platform/browser'. [D:\home\site\repository\LearnJS\LearnJS.Web\LearnJS.Web.csproj] 
D:\home\site\repository\LearnJS\LearnJS.Web\app\main.ts(2,32): error TS2307: Build: Cannot find module 'angular2/router'. [D:\home\site\repository\LearnJS\LearnJS.Web\LearnJS.Web.csproj] 
Failed exitCode=1, command="D:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" "D:\home\site\repository\LearnJS\LearnJS.Web\LearnJS.Web.csproj" /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="D:\local\Temp\8d33697b325b07b";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false /p:SolutionDir="D:\home\site\repository\LearnJS\\" 
An error has occurred during web site deployment. 
\r\nC:\Program Files (x86)\SiteExtensions\Kudu\51.50212.2079\bin\scripts\starter.cmd "D:\home\site\deployments\tools\deploy.cmd" 

看來,構建主機不找角度模塊。我瞭解這些模塊存在於./node_modules目錄中,但未登錄到我的存儲庫。我有一個package.json服務器中的資源,它看起來像這樣:

{ 
    "name": "angular2-quickstart", 
    "version": "1.0.0", 
    "scripts": { 
    "tsc": "tsc", 
    "tsc:w": "tsc -w", 
    "lite": "lite-server", 
    "start": "concurrent \"npm run tsc:w\" \"npm run lite\" " 
    }, 
    "license": "ISC", 
    "dependencies": { 
    "angular2": "2.0.0-beta.0", 
    "systemjs": "0.19.6", 
    "es6-promise": "^3.0.2", 
    "es6-shim": "^0.33.3", 
    "reflect-metadata": "0.1.2", 
    "rxjs": "5.0.0-beta.0", 
    "zone.js": "0.5.10" 
    }, 
    "devDependencies": { 
    "concurrently": "^1.0.0", 
    "lite-server": "^1.3.4", 
    "typescript": "^1.7.5" 
    } 
} 

問題

什麼我需要做的就是天青,能讓這些node.js的模塊部署站點時, ?

我應該只檢查我的node_modules目錄嗎?但它似乎是針對this question

事情我已經試過

我安裝Azure的命令行界面,並試圖通過this post的建議來運行這個命令。

azure site deploymentscript --node 

但我得到這個錯誤enter image description here

更新2016年2月18日:

重新運行azure site deploymentscript --node命令,生成兩個文件:.deploymentdeploy.cmd。將兩個文件都提交到主分支。在日誌的第一線仔細觀察,蔚藍的運行從這個目錄

D:\home\site\deployments\tools\deploy.cmd 

我需要在我的項目創建一個目錄deployments\tools還是我把deploy.cmd在錯誤的地方deploy.cmd?我仍然有相同的構建錯誤。

部分日誌文件在檢查兩個部署文件後。

Command: "D:\home\site\deployments\tools\deploy.cmd" 
Handling .NET Web Application deployment. 
MSBuild auto-detection: using msbuild version '14.0' from 'D:\Program Files (x86)\MSBuild\14.0\bin'. 
All packages listed in packages.config are already installed. 
D:\home\site\repository\LearnJS\LearnJS.Web\app\app.component.ts(1,41): error TS2307: Build: Cannot find module 'angular2/core'. 

這是部署。CMD文件:

@if "%SCM_TRACE_LEVEL%" NEQ "4" @echo off 

:: ---------------------- 
:: KUDU Deployment Script 
:: Version: 1.0.6 
:: ---------------------- 

:: 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=%appdata%\npm\kuduSync.cmd 
) 
goto Deployment 

:: Utility Functions 
:: ----------------- 

:SelectNodeVersion 

IF DEFINED KUDU_SELECT_NODE_VERSION_CMD (
    :: The following are done only on Windows Azure Websites environment 
    call %KUDU_SELECT_NODE_VERSION_CMD% "%DEPLOYMENT_SOURCE%" "%DEPLOYMENT_TARGET%" "%DEPLOYMENT_TEMP%" 
    IF !ERRORLEVEL! NEQ 0 goto error 

    IF EXIST "%DEPLOYMENT_TEMP%\__nodeVersion.tmp" (
    SET /p NODE_EXE=<"%DEPLOYMENT_TEMP%\__nodeVersion.tmp" 
    IF !ERRORLEVEL! NEQ 0 goto error 
) 

    IF EXIST "%DEPLOYMENT_TEMP%\__npmVersion.tmp" (
    SET /p NPM_JS_PATH=<"%DEPLOYMENT_TEMP%\__npmVersion.tmp" 
    IF !ERRORLEVEL! NEQ 0 goto error 
) 

    IF NOT DEFINED NODE_EXE (
    SET NODE_EXE=node 
) 

    SET NPM_CMD="!NODE_EXE!" "!NPM_JS_PATH!" 
) ELSE (
    SET NPM_CMD=npm 
    SET NODE_EXE=node 
) 

goto :EOF 

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

:Deployment 
echo Handling node.js deployment. 

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

:: 2. Select node version 
call :SelectNodeVersion 

:: 3. Install npm packages 
IF EXIST "%DEPLOYMENT_TARGET%\package.json" (
    pushd "%DEPLOYMENT_TARGET%" 
    call :ExecuteCmd !NPM_CMD! install --production 
    IF !ERRORLEVEL! NEQ 0 goto error 
    popd 
) 

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

:: Post deployment stub 
IF DEFINED POST_DEPLOYMENT_ACTION call "%POST_DEPLOYMENT_ACTION%" 
IF !ERRORLEVEL! NEQ 0 goto error 

goto end 

:: Execute command routine that will echo out when error 
:ExecuteCmd 
setlocal 
set _CMD_=%* 
call %_CMD_% 
if "%ERRORLEVEL%" NEQ "0" echo Failed exitCode=%ERRORLEVEL%, command=%_CMD_% 
exit /b %ERRORLEVEL% 

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

:exitSetErrorLevel 
exit /b 1 

:exitFromFunction 
() 

:end 
endlocal 
echo Finished successfully. 
+0

您使用ASPNet 5/Core 1.0嗎? –

+0

我的確是作爲一個空的ASP Net項目開始的,但客戶端是用純TypeScript和Angular 2(beta 0)構建的。我將* .csproj附加到問題中。我正在使用Visual Studio 2013更新5 –

+0

您的應用程序是純客戶端嗎?沒有.Net代碼?或者它是一個NodeJS應用程序? –

回答

1

根據我的理解,我覺得你的需求是創造與打字稿和2角的靜態Web項目,然後通過GitHub的持續部署部署靜態網站到Web應用程序天青。

最簡單的方法是在VS中用nodejs工具創建一個靜態web項目,然後僅爲這些靜態web頁面開發,這些靜態web頁面包含從ts文件編譯的js文件,然後將它們提交到您創建的GitHub存儲庫,並設置連續從Azure門戶上的Azure WebApp的GitHub部署。

所以我認爲你可以嘗試參考其他回答SO線程Deploying Hexo on Azure.. not sure what i'm missing知道如何去做。

0

Node的部署腳本工作,問題是您在非管理命令提示符的硬盤根目錄上使用它。

可以使用管理權限打開命令提示符,也可以在用戶擁有寫入權限的文件夾(可能位於「您的文檔」文件夾中)上運行該命令提示符。

nodejs deployment script generation

生成的文件添加到您的Web應用程序文件夾中。你不需要創建一個VS.csproj,因爲它只是一個客戶端應用程序。

Typescript是您的'devDependencies'之一,這意味着它在您的開發環境中運行,它應該將.ts文件編譯爲.js文件。您應該將這些編譯後的.js文件推送到您的倉庫,並在您的頁面中引用它們。

+0

感謝您的回覆。我將兩個生成的文件* .deployment和deploy.cmd文件提交到存儲庫。但是azure仍然認爲它是一個.Net Web應用程序,可能是因爲我創建了一個ASP。 NET項目。我仍然結束了構建錯誤。詳情請參閱我的更新。 –

+0

deploy.cmd和.deployment文件需要位於回購的根目錄下。刪除.csproj文件,它可能會導致Kudu認爲它是一個.Net應用程序:) –