You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure中deploy.cmd缺失,自定义部署实现MS单元测试自动化遇阻求助

Troubleshooting Missing deploy.cmd & Adding MS Unit Tests to Custom Deployment Scripts

Hey there, let's walk through fixing your deployment script issues and getting those MS Unit Tests running automatically.

First: Fixing the Missing deploy.cmd File

If you can't find deploy.cmd in Site\deployments\tools, here's how to get it:

  • Generate it locally with Azure CLI: Open your terminal and run this command (replace placeholders with your app details):
    az webapp deployment script --name <your-app-service-name> --resource-group <your-resource-group> --script-type cmd
    
    This will create a deploy.cmd file and a .deployment config file right on your local machine—you can edit these before uploading.
  • Check Kudu Console: Log into your app's Kudu dashboard, navigate to site\deployments. If the tools folder doesn't exist, trigger a basic deployment first (like pushing a small change to your repo) to generate default deployment artifacts, or upload your manually created deploy.cmd directly.

Fixing Deployment Script Download Failures

If the Portal's "Download deployment scripts" tool isn't working:

  • Try Kudu directly: In Kudu, go to Tools > Download deployment script—this often bypasses Portal caching issues. If that still fails, use the Azure CLI method above to generate the script locally instead.
  • Clear Portal cache: Refresh the Azure Portal page, or open it in an incognito window to rule out cached errors.

Adding MS Unit Tests to Your Custom Script

Once you have deploy.cmd, edit it to add test execution steps. Here's a typical example:

  1. Restore dependencies first (add this before the deployment step):
    :: Restore NuGet packages for test project
    cd "%DEPLOYMENT_SOURCE%\YourTestProjectDirectory"
    nuget restore YourTestProject.csproj
    
  2. Run the tests (place this right before the deployment starts, or after build completes):
    :: Execute MS Unit Tests
    cd "%DEPLOYMENT_SOURCE%\YourTestProjectDirectory\bin\Release"
    "%ProgramFiles(x86)%\Microsoft Visual Studio\2022\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" YourTestProject.dll /Logger:trx
    
    Note: Adjust the Visual Studio version path and test DLL name to match your setup.

Deploying Your Custom Script

  • Upload your edited deploy.cmd and the .deployment file (make sure it has a [config] section pointing to deploy.cmd) to the root of your deployment source (Git repo, blob storage, etc.). Azure will automatically use this custom script for future deployments.

内容的提问来源于stack exchange,提问作者Ragu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 03:40:39