Azure Web App (MVC 6) continuous deployment fails

2020-04-10 06:34发布

问题:

I'm trying to set up continous deployment for an Azure Web App from Bitbucket. The deployment however fails with the following error:

Command: deploy.cmd
Handling ASP.NET 5 Web Application deployment.
Invoke-Command : Cannot validate argument on parameter 'Architecture'. The 
argument "undefined" does not belong to the set ",x86,x64,arm" specified by 
the ValidateSet attribute. Supply an argument that is in the set and then try 
the command again.
At C:\Program Files 
(x86)\SiteExtensions\Kudu\49.41216.1976\bin\scripts\dnvm.ps1:1914 char:9
+         Invoke-Command ([ScriptBlock]::Create("dnvm-$cmd $cmdargs"))
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidData: (:) [Invoke-Command], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Power   
Failed exitCode=1, command=PowerShell -NoProfile -NoLogo -ExecutionPolicy
unrestricted -Command "
[System.Threading.Thread]::CurrentThread.CurrentCulture = '';
[System.Threading.Thread]::CurrentThread.CurrentUICulture = '';$CmdPathFile='"D:\local\UserProfile\.dnx\temp-set-envvars.cmd"';&
'C:\Program Files (x86)\SiteExtensions\Kudu\49.41216.1976\bin\scripts\dnvm.ps1' " install undefined -arch undefined -r undefined
Shell.Commands.InvokeCommandCommand

An error has occurred during web site deployment.

The publish/deployment directly from Visual Studio 2015 works without any problems. It seems like the dnvm.ps1 command is passed a bunch of "undefined" arguments causing this error. Creating the deployment script locally (as instructed here) by running

azure site deploymentscript --aspNet5 <path to the project.json file>

will also generate the deploy.cmd with same "undefined" variables.

I'm not using any custom deployment scripts and my global.json looks like:

{
  "projects": [ "src", "test" ],
  "sdk": {
    "version": "1.0.0-rc1-update1"
  }
}

回答1:

The problem occurred because I had run azure site deploymentscript --aspNet5 <path to the project.json file> that generates deploy.cmd file locally. That file is then used by the Azure deployment if it exists. The local deploy.cmd had undefined parameters due to a bug in the generator. Removing the deploy.cmd solved this issue.



回答2:

I ended up having to explicitly specify these as arguments when re-running the deployment script generator.

azure site deploymentscript --aspNet5 sr\[myprojectfolder]\ --aspNet5Version 1.0.0-rc1-update1 --aspNet5Architecture x64 --aspNet5Runtime CLR

As specifying them in the global.json first as suggested by automatonicand then re-running didn't have any effect, I assume this is a bug.



回答3:

Your global.json file can define a runtime and an architecture:

{
  "projects": [ "src", "test" ],
  "sdk": {
    "version": "1.0.0-rc1-update1",
    "runtime": "clr",
    "architecture": "x64"
  }
}

I am guessing the scripts are pulling from those values and don't know how to cope with them being missing from global.json?