Reputation: 8982
I'm struggling to publish a project from the command line. Here are the steps I've taken:
Created a brand new ASP.NET MVC 3 (internet) project
in
Visual Studio 2012
Added a publish File System
profile using the publish wizard and specified the destination directory.
Clicking publish successfully deployed the app to the location specified.
Added a second publish profile but this time a Web Deploy
profile. Specified the server, the site name, a username and
password for an account that I use to remote desktop
to the
server. Clicked Validate Connection
. It displays a small "tick"
image to denote success.
Clicking publish Successfully deploys the app to the remote server.
So in summary, when I use the publish wizard from within Visual Studio I can successfully deploy to the local file system or a remote server using Web Deploy.
Then I switch to the command line
msbuild MyMVCProject.csproj /p:DeployOnBuild=true /p:PublishProfile=PublishToFileSystem.pubxml /p:VisualStudioVersion=11.0
Deploys successfully to the local file system.
However
msbuild MyMVCProject.csproj /p:DeployOnBuild=true /p:PublishProfile=BuildServer.pubxml /p:VisualStudioVersion=11.0 /p:AllowUntrustedCertificate=true
Returns the following error:
msdeploy error ERROR_USER_UNAUTHORIZED: Web deployment task failed. (Connected to the remote computer ("10.0.1.6") 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 connecting 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.)
The page it mentioned in the error message didn't really help me.
Can anyone help, why can I deploy without an issue from the Visual Studio publishing wizard and not from the command line?
Upvotes: 0
Views: 1530
Reputation: 8982
The solution turned out to be very simple. I simply needed to add /p:Password=<insert password here>
as a parameter on the command line. I supplied the password in the publish
wizard, but for security purposes this isn't stored in the .pubxml
file.
Actually I discovered this from a 'supplement' book by SAYED IBRAHIM HASHIMI
. The book is titled Supplement to Inside the Microsoft Build Engine.
Upvotes: 1