2

I have a .NET framework project with a publish profile using an encrypted password. So I have 2 publish files: .pubxml and .pubxml.user (this one contains the encrypted password).

However, if I run msbuild like this:

msbuild <project>.csproj /p:DeployOnBuild /p:PublishProfile=<file>.pubxml 

I get a 401 authentication error.

Is it possible to pass the encrypted password somehow, or telling msbuild to use the .pubxml.user file?

KeL666
  • 23
  • 1
  • 6
  • Any update for this issue? Have you resolve this issue? If not, please let me know the latest status for this issue. – Leo Liu Oct 09 '17 at 09:40
  • No, unfortunately I think your answer was right, so I'm passing the password directly to the command – KeL666 Oct 10 '17 at 10:53

1 Answers1

3

Is it possible to pass the encrypted password somehow, or telling msbuild to use the .pubxml.user file?

It is impossible to pass the encrypted password by MSBuild command line. Just as you said, the .pubxml.user file contains the password in encrypted form. This file can not be accessed by MSBuild when you deploy by MSBuild command line.

Besides, as aware as i know, the encrypted password is used for per-account and per-machine. So when you deploy your project to a different machine or account, encrypted password will be invalid when you deploy your project to the another machines or account.

So we need to pass the actual name and password with MSBuild command line;

msbuild <path-to-project-file> /p:DeployOnBuild=true /p:PublishProfile=<Publish Profile> /p:Username=<ACTUAL_USERNAME> /p:Password=<ACTUAL_PASSWORD>

See the Sayed`s answer and this document for more detail info.

Hope this helps.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • 4
    So Visual Studio has encrypted password stored in the *.pubxml.user file which Visual Studio can use just fine, but there is no way to automate publish with msbuild (assuming same user and machine that where using Visual Studio) except for exposing the password in clear text. If this is true then where should this bug be reported? – NiKiZe Aug 23 '18 at 20:13