How can I get TFS2010 to run MSDEPLOY for me through MSBUILD?

后端 未结 8 1653
北海茫月
北海茫月 2020-11-28 17:47

There is an excellent PDC talk available here from Vishal Joshi which describes the new MSDEPLOY features in Visual Studio 2010 - as well as how to deploy an application wit

相关标签:
8条回答
  • 2020-11-28 18:01

    Here's how I got it to work. This was with Webdeploy 2.0. I am deploying on the same domain from our build machine to a dev webserver machine windows server 2008 r2. The account I am using to deploy is a service account on the domain that has administrator permissions on both machines. My solution includes a couple of unit test projects, an mvc3 project, and a couple of libraries under the solution. If you don't install MVC3 on the server you are deploying to look at http://www.iwantmymvc.com/2011-03-23-bin-deploy-aspnet-mvc-3-visual-studio for guidance.

    /p:DeployOnBuild=True /p:DeployTarget=MSDeployPublish /p:DeployIisAppPath="Default Web Site/YourpplicationNameHere" /p:MsDeployServiceUrl=https://devserver02:8172/msdeploy.axd /p:AllowUntrustedCertificate=True /p:UserName=yourDomain\buildaccount /p:Password=password

    1. The item I struggled with at first were the quotes around "Default Web Site/YourpplicationNameHere" That gives the partial error:

      MSBUILD : error MSB1008: Only one project can be specified.

      This happens when there are no quotes around Default Web Site/YourApplicationNameHere

    2. The next error I got was because of the wrong username and password in my credentials for deployment. It gave this error:

      C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets (3588): Web deployment task failed.(Remote agent (URL https://devserver02:8172/msdeploy.axd?site=Default Web Site) could not be contacted. Make sure the remote agent service is installed and started on the target computer.) Make sure the site name, user name, and password are correct. If the issue is not resolved, please contact your local or server administrator. Error details: Remote agent (URL https://devserver02:8172/msdeploy.axd?site=Default Web Site) could not be contacted. Make sure the remote agent service is installed and started on the target computer. An unsupported response was received. The response header 'MSDeploy.Response' was '' but 'v1' was expected. The remote server returned an error: (401) Unauthorized.

      This was because the username and password I had in /p:UserName=/p:Password=did not include the domain for the user. Even though it the build was running under that user it would not deploy. So I hit the url directly https://devserver02:8172/msdeploy.axd in a browser to make sure it was operation and make sure the username and password worked. This is where I noticed I had to put in the domain/user to get it to work.

    I hope this is OK to reply I figured some other poor soul with find these errors and this could help...

    0 讨论(0)
  • 2020-11-28 18:03

    Unfortunately there is not a lot of info on this at this time. I'll give you some hints at the end of this message though.


    About your problem, I've seen this before when I was trying to deploy using MSDeploy and the account that I was running on didn't have the permissions to execute the deployment on the target machine. So you need to take a look at the account that your builds are running under, and see if this account has the rights to deploy to the target machine. If not then you have a few options; grant the build user the rights, or pass the username/password in.

    If you want to pass the values in then you will have to define an item named MsDeployDestinationProviderSetting and its metadata will have to contain the necessary values.

    So in your project file (or via properties passed in) define something like the following.

    <PropertyGroup>
        <UserName>USERNAME-HERE</UserName>
        <Password>PASSWORD-HERE
    </PropertyGroup>
    

    About where can you find documentation, like I said before there is not much out there yet. But since the entire Web Publishing Pipeline is captured in MSBuild targets and tasks you can learn alot on your own if you are familiar with MSBuild. If you take a look at the .csproj(or .vbproj) files for web projects created with Visual Studio 2010 you'll notice a statement like the following:

    <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
    

    This imports the file located at %ProgramFiles(x86)%\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets, and this file in turn imports %ProgramFiles(x86)%\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets

    So in order to learn this topic in detail right now you have to inspect those files and learn for yourself.


    I'm going to be working on something that will be covering these technologies in detail, but it won't be out for quite a while, and I still have a lot to figure out myself about this stuff.

    Can you try out the username/password deal and let me know if it worked for you?

    0 讨论(0)
  • 2020-11-28 18:04

    For me the problem was that Web Deployment Agent Service was not started.

    A simple net start msdepsvc fixed it. You could also set startup mode to Automatic on this service.

    The arguments I'm using are:

    /p:DeployOnBuild=True 
    /p:DeployTarget=MsDeployPublish 
    /p:MSDeployPublishMethod=RemoteAgent 
    /p:MSDeployServiceUrl=stagingserver 
    /p:DeployIisAppPath=test.local 
    /p:UserName=
    

    You only need to specify the server name, and not the full path (no http needed).

    Note that UserName is left empty to work around a bug with NTLM authentication (this way it uses the credentials of the TFS build agent for the deployment). see the accepted answer here

    0 讨论(0)
  • 2020-11-28 18:09

    Here's the steps that finally worked for me. I wanted to get the working with RemoteAgent, but couldn't get that working no matter what I tried.

    You don't have to do exactly like this, but this is how I got it working

    • Configure WMSVC
    • Make sure the service is started
    • Configure an IIS user (click on the TOP MOST SERVERNAME in IIS) and go to 'IIS Manager Users'. I suggest making it different to your windows name.
    • Make sure the user account for WMSVC (LOCAL SERVICE for me) has write permissions to the IIS directory you're using
    • In my case I'm using an SSL certificate (even though it is hitting localhost).

    Remember these are all arguments to MSBUILD added within the TFS Build definition

    /p:DeployOnBuild=True 
    /p:DeployTarget=MSDeployPublish 
    /p:MSDeployPublishMethod=WMSVC 
    /p:MsDeployServiceUrl=https://staging.example.com:8172/msdeploy.axd 
    /p:username=sweaveriis 
    /p:password=abcd1234 
    /p:DeployIisAppPath=staging.example.com/virtual_directory_name
    /p:AllowUntrustedCertificate=True
    

    Note: staging.example.com is actually the local box with a hosts file entry pointing to 127.0.0.1. Localhost would probably work here too.

    Useful articles:

    Troubleshooting MSDeploy issues

    More troubleshooting

    0 讨论(0)
  • 2020-11-28 18:09

    I had a similar problem and the solution was to have the following parameter:

    /p:MSDeployPublishMethod=RemoteAgent

    Here are all of the parameters I used.

    /p:DeployOnBuild=True /p:DeployTarget=MSDeployPublish /p:MSDeployPublishMethod=RemoteAgent /p:MsDeployServiceUrl=http://my-server-name /p:username=myusername /p:password=mypassword

    NOTE: I'm not using DeployIisAppPath because I'm building a solution and trying to build three web applications at once. Also I think your MsDeployServiceUrl should be just http://staging.example.com

    It appears that when using InProc (which may be the default) for the MSDeployPublishMethod MSBuild ignores MsDeployServiceUrl and always tries to deploy to the local server. I changed it to RemoteAgent and all three of my web applications deployed successfully. I did notice that the Package file is nolonger contained in the MyWebApplication_Package folder, but that isn't a big deal to me.

    0 讨论(0)
  • 2020-11-28 18:11

    Note that you can also set DeployTarget=Package -- this will prepare the package but not deploy it right away. For more info see this blog post.

    0 讨论(0)
提交回复
热议问题