2016-01-22 45 views
0

我們有一個使用VS2015.1創建的解決方案,其中包含3個項目,全部爲DNX RC1DNX Webjob無法解決本地項目依賴性

| sln 
|+---MVC6 Api 
|  project.json 
| +---ClassLibrary 
|  Class.cs 
|  project.json 
| \---Webjob 
     Program.cs 
     project.json 

API和Webjob都在其project.json文件中引用ClassLibrary。

"frameworks": { 
    "dnx451": { 
     "dependencies": { 
     "ClassLibrary": "1.0.0-*" 
     } 
    } 
    } 

我們創建2周的WebApp,均與連續型的集成捆綁解決方案回購和每一個項目應用程序設置指向API文件夾(在一個)和Webjob文件夾(在其他)。

的API項目被部署沒有問題,當它試圖解決本地項目依賴它的工作原理:

Using Project dependency ClassLibrary 1.0.0 for DNX,Version=v4.5.1 
Copying source code from Project dependency ClassLibrary 
    Source D:\home\site\repository\ClassLibrary\project.json 
    Target D:\local\Temp\8d32044390806ef\approot\src\ClassLibrary 

在另一方面,Webjob,失敗,它試圖解決它作爲一個的NuGet遠程包和失敗:

[01/21/2016 19:47:45 > b597c3: INFO] GET https://api.nuget.org/v3-flatcontainer/ClassLibrary/index.json 
[01/21/2016 19:47:46 > b597c3: INFO] NotFound https://api.nuget.org/v3-flatcontainer/ClassLibrary/index.json 507ms 
[01/21/2016 19:47:46 > b597c3: ERR ] Unable to locate Dependency ClassLibrary >= 1.0.0-* 

最後這部分我不得不通過捻來檢查它,因爲它是在部署階段(如與API)上WebJob明顯,而不是在第一次運行完成。

在本地運行WebJob工作沒有問題。

我試過在publish dnx based WebJob with local dependencies的解決方案,但沒有奏效。

回答

1

在與產品團隊交談之後,默認情況下,3項目方案現在不會正常工作。

publish dnx based WebJob with local dependencies上描述的解決方案適用於2個項目場景,但如果您需要部署WebJob和依賴於相同類庫項目的Web應用程序,並且3個應用於相同的回購站,則無法來自持續集成的Webjob部署。

解決方案是爲您的Web應用程序設置持續集成(默認情況下它將起作用)並將WebJob手動部署爲壓縮文件。

進入您的WebJob文件夾並運行dnu publish

進入bin/output/approot/src/YourWebJobFolder

編輯自動生成CMD文件

使用此腳本通過自定義線路4:

@ECHO OFF 

:: 1. Prepare environment 
SET DNX_CONSOLE_APP_PATH=Autocosmos.Trunk.Webjob 
SET DNVM_CMD_PATH_FILE="%USERPROFILE%\.dnx\temp-set-envvars.cmd" 

:: 2. Install DNX 
CALL PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';$CmdPathFile='%DNVM_CMD_PATH_FILE%';& '%SCM_DNVM_PS_PATH%' " install latest 
IF ERRORLEVEL 1 GOTO ERROR 

:: 3. Put DNX on the path 
IF EXIST %DNVM_CMD_PATH_FILE% (
    CALL %DNVM_CMD_PATH_FILE% 
    DEL %DNVM_CMD_PATH_FILE% 
) 

call :ExecuteCmd dnx --project "%~dp0src\%DNX_CONSOLE_APP_PATH%" --configuration Release %DNX_CONSOLE_APP_PATH% run 

goto end 

: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. 

然後ZIP斌/輸出/爲approot上傳它Azure上。

相關問題