Ismail
Ismail

Reputation: 993

Cannot webdeploy using msbuild but can with visual studio

I am attempting to deploy asp.net mvc project using web deploy. In visual studio I have setup a profile called dev. I can publish the project through visual studio 2019 no problem.

I am trying to setup deploy using jenkins using pipeline script. My command to deploy looks like:

msbuild /P:PublishProfile=Dev /P:DeployOnBuild=true

This command creates the deployment assets and attempts to publish however fails with error:

MSDeployPublish: Start Web Deploy Publish the Application/package to https://1.1.1.1:8172/msdeploy.axd?site=somesite.someserver.com ... Starting Web deployment task from source: manifest(c:\Code\MyProject\AdminWebsite\obj\Dev\Package\AdminWebsite.SourceManifest.xml) to Destination: auto(). C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VisualStudio\v16.0\Web\Microsoft.Web.Publishing.targets(4284,5): msdeploy error ERROR_USER_UNAUTHORIZED: Web deployment task fa iled. (Connected to the remote computer ("1.1.1.1") using the Web Management Service, but could not authorize. Make sure that you are using the correct user name and password, that the site you are connecti ng to exists, and that the credentials represent a user who has permissions to access the site. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_UNAUTHORIZED.)

Note that I can publish using that same profile using visual studio but on same machine via command line i cannot.

Note: I have changed ips and project names etc in this post to obscure my actual settings.

Anyone any ideas?

Upvotes: 0

Views: 863

Answers (2)

Adjetey Adjei-laryea
Adjetey Adjei-laryea

Reputation: 11

Using single quote on the password worked for me. Double quotes didn't work.

msbuild /P:PublishProfile=Dev /p:DeployOnBuild=true /P:Password='12334Ykz#2pE&AJJ'

Upvotes: 1

Ismail
Ismail

Reputation: 993

So got this working. I updated my command to pass through password like:

msbuild /P:PublishProfile=Dev /p:DeployOnBuild=true /P:Password=12334Ykz#2pE&AJJ

On the command line right at end i was getting AJJ unknown command

So i updated my command to

msbuild /P:PublishProfile=Dev /p:DeployOnBuild=true /P:Password="12334Ykz#2pE&AJJ"

and it works, looks like it did not like the & in password

Upvotes: 0

Related Questions