executecmd”

b4lqfgs4  于 2021-06-20  发布在  Kudu
关注(0)|答案(0)|浏览(196)

我在azure应用程序服务上成功运行了一个react应用程序。现在我添加了对env变量的支持,但是现在deploy.cmd kudu脚本失败,错误消息是“系统找不到指定的批标签-executecmd”。
deploy.cmd命令:

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

:: ----------------------
:: KUDU Deployment Script
:: Version: 1.0.13
:: ----------------------

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

IF NOT DEFINED DEPLOYMENT_SOURCE (
  SET DEPLOYMENT_SOURCE=%~dp0%\build
)

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
)

:: Install dependencies
echo Install dependencies
call :ExecuteCmd npm install
IF !ERRORLEVEL! NEQ 0 goto error

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

echo Handling Basic Web Site deployment.

:: 1. Build of the react script app
echo Build the app first

call :ExecuteCmd npm run build
IF !ERRORLEVEL! NEQ 0 goto error

:: 2. KuduSync
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
  call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f "..\repository\build" -t 
"..\wwwroot" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i 
".git;.hg;.deployment;deploy.cmd"
  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.

我将package.json中的脚本从

"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }

"scripts": {
    "start": "cross-env REACT_APP_SERVER=staging react-scripts start",
    "start:production": "cross-env REACT_APP_SERVER=production react-scripts start",
    "build": "cross-env REACT_APP_SERVER=production react-scripts build",
    "build:staging": "cross-env REACT_APP_SERVER=staging react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }

如果我在windows下测试一个干净的安装,一切都正常,所以脚本看起来还可以。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题