none
DNX Webjob fails to resolve local project dependencies RRS feed

  • Question

  • We have a Solution created with VS2015.1 that has 3 projects, all of them DNX RC1.

    | sln

    |+---MVC6 Api

    |      project.json

    | +---ClassLibrary

    |      Class.cs

    |      project.json

    | \---Webjob

           Program.cs  

          project.json

    Both the API and Webjob reference the ClassLibrary in their project.json files.

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

    We created 2 WebApps, both tied with Continuos Integration to the Solution repo and each with a Project Application Setting that points to the API folder (in one) and the Webjob folder (in the other).

    The API project gets deployed without problem, when it tries to resolve the local project dependency it works:

    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

    The Webjob on the other hand, fails, it tries to resolve it as a nuget remote package and fails:

    [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-*

    This last part I had to check it through Kudu, since it's done on the first run of the WebJob apparently and not during the deploy phase (like with the API).

    Running the WebJob locally works without issues.


    • Edited by Ealsur Thursday, January 21, 2016 8:54 PM
    Thursday, January 21, 2016 8:51 PM

Answers

  • I managed to get it working, just not with Continuous Integration. The scenario with 3 Projects won't work. There is a solution for the 2 Projects scenario (Webjob+ClassLibrary) described here.

    To manually deploy the Webjob, you have to use 'dnu publish' in your Webjob folder.

    It will create a "bin/output/approot" folder.

    Then go into that folder, you'll find a "src" folder, inside, all your Solution folders, get in the Webjob one and edit the CMD file to look like this:

    @ECHO OFF
    
    :: 1. Prepare environment
    SET DNX_CONSOLE_APP_PATH=YourWebJobFolderName
    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 the "bin/output/approot" folder and Upload it, it should work now :)


    • Marked as answer by Ealsur Monday, February 15, 2016 5:26 PM
    • Edited by Ealsur Monday, February 15, 2016 5:41 PM spelling
    Monday, February 15, 2016 5:25 PM

All replies

  • Hello Ealsur,

    I am currently checking on this and will get back to you shortly. Thank you for your patience.

    Thanks,
    Syed Irfan Hussain

    Friday, January 22, 2016 2:43 PM
    Moderator
  • Thanks Syed :) I understand this whole DNX thing is new and there might be cases not yet found or tested.
    Friday, January 22, 2016 2:45 PM
  • Equally interested in this scenario.

    What I've tried is also to use `dnu publish` to include the referenced project(s).  The end result from logs in Kudu:

    [02/05/2016 19:03:13 > 3b3a4f: SYS ERR ] Failed to copy job files: System.Threading.ThreadAbortException: Thread was being aborted.
       at Kudu.Core.Infrastructure.OperationManager.Attempt[T](Func`1 action, Int32 retries, Int32 delayBeforeRetry, Func`2 shouldRetry)
       at Kudu.Core.Infrastructure.OperationManager.Attempt(Action action, Int32 retries, Int32 delayBeforeRetry)
       at Kudu.Core.Jobs.BaseJobRunner.CacheJobBinaries(JobBase job, IJobLogger logger)[02/05/2016 19:03:50 > 3b3a4f: SYS INFO] Run script 'WebJob.cmd' with script host - 'WindowsScriptHost'
    [02/05/2016 19:03:50 > 3b3a4f: SYS INFO] Status changed to Running
    [02/05/2016 19:03:50 > 3b3a4f: ERR ] '"dnx.exe"' is not recognized as an internal or external command,
    [02/05/2016 19:03:50 > 3b3a4f: ERR ] operable program or batch file.[02/05/2016 20:49:39 > 3b3a4f: SYS ERR ] Job failed due to exit code 1
    [02/05/2016 20:49:39 > 3b3a4f: SYS INFO] Process went down, waiting for 60 seconds
    [02/05/2016 20:49:39 > 3b3a4f: SYS INFO] Status changed to PendingRestart

    Friday, February 5, 2016 8:50 PM
  • Hi Syed, its been more than 2 weeks, any news?
    Monday, February 8, 2016 2:04 AM
  • Hello Ealsur,

    I apologize for the delay, I am still checking with the operations team and will get back to you.

    Thanks,
    Syed Irfan Hussain

    Tuesday, February 9, 2016 12:21 PM
    Moderator
  • I managed to get it working, just not with Continuous Integration. The scenario with 3 Projects won't work. There is a solution for the 2 Projects scenario (Webjob+ClassLibrary) described here.

    To manually deploy the Webjob, you have to use 'dnu publish' in your Webjob folder.

    It will create a "bin/output/approot" folder.

    Then go into that folder, you'll find a "src" folder, inside, all your Solution folders, get in the Webjob one and edit the CMD file to look like this:

    @ECHO OFF
    
    :: 1. Prepare environment
    SET DNX_CONSOLE_APP_PATH=YourWebJobFolderName
    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 the "bin/output/approot" folder and Upload it, it should work now :)


    • Marked as answer by Ealsur Monday, February 15, 2016 5:26 PM
    • Edited by Ealsur Monday, February 15, 2016 5:41 PM spelling
    Monday, February 15, 2016 5:25 PM