Ventsyslav Raikov
Ventsyslav Raikov

Reputation: 7192

web deploy from a folder with spaces

I have a very simple scenario, ASP.NET MVC4 web site. I use the Publish functionality of VS2012 to generate web deploy package. This generates a bunch of files, one .zip, some .xml and a xxx.deploy.cmd file.

I run the deploy.cmd file as usual with the following command:

MVCTestApp.deploy.cmd /Y -enableRule:DoNotDeleteRule

When run from a subfolder of program files, which contains spaces(for instance C:\Program Files (x86)\Folder With Spaces\TestApp) this command fails with the error

\Folder was unexpected at this time.

The problem is apparently in the handling of the _DeploySetParametersFile parameter, but I can't just fix the .cmd file because it is generated on each publish.

Does anyone have a workaround for this?

Upvotes: 3

Views: 2088

Answers (2)

Nick
Nick

Reputation: 6588

You might need set the value of the _DeploySetParametersFile parameter before you call the .cmd if that is what is causing the problem. Create another static batch file which you will use to do this.

First, set the value of the parameter with escaped spaces, then just call the cmd from its location. Use this batch file each time you need to deploy the application. Full Contents:

@if %_echo%!==! echo off
setlocal
set _DeploySetParametersFile=C:\Program^ Files^ (x86)\Folder^ With^ Spaces\TestApp\xxx.SetParameters.xml
"C:\Program Files (x86)\Folder With Spaces\TestApp\xxx.Deploy.cmd"

Call the file something like mydeploy.cmd and call it from the command line so that you can reply with any errors rather than the window closing immediately.

Upvotes: 1

Chris B. Anilao
Chris B. Anilao

Reputation: 73

For me the issue was related to the link below (I was trying to get this to work in jenkins):

https://issues.jenkins-ci.org/browse/JENKINS-11992?focusedCommentId=201790#comment-201790

I worked around the issue by using the shortened versions of the directories. You can find out what what they are by typing dir /x.

My build command ended up looking like this:

MSBuild c:\PROGRA~2\Jenkins\jobs\REPVIE~1\workspace\Builder\RepView\RepView.csproj /p:DeployOnBuild=true /p:PublishProfile=JenkinsDeployment

My deploy command ended up looking like this:

c:\PROGRA~2\Jenkins\jobs\REPVIE~1\workspace\Builder\RepView\obj\Debug\Package\RepView.deploy.cmd /y /M:http://<target-address> /u:<username> /p:<password>

Because the deploy.cmd file is generated, using the shortened names for the directories when MSBuild is called, gets around this issue. Just don't use any paths with spaces and it should work for you.

Upvotes: 3

Related Questions