Development Tip

TFS2010에서 MSBUILD를 통해 MSDEPLOY를 실행하려면 어떻게해야합니까?

yourdevel 2020. 10. 12. 08:16
반응형

TFS2010에서 MSBUILD를 통해 MSDEPLOY를 실행하려면 어떻게해야합니까?


Visual Studio 2010의 새로운 MSDEPLOY 기능과 TFS 내에서 응용 프로그램을 배포하는 방법에 대해 설명하는 Vishal Joshi 의 훌륭한 PDC 강연이 있습니다 . ( Scott Hanselman 의 훌륭한 이야기도 있지만 TFS에 참여하지 않습니다.)

TFS2010 내에서 MSBUILD를 사용하여 MSDEPLOY를 호출하여 패키지를 IIS에 배포 할 수 있습니다. 이는 MSBUILD에 대한 매개 변수를 통해 수행됩니다.

이 강연에서는 다음과 같은 일부 명령 줄 매개 변수를 설명합니다.

/p:DeployOnBuild
/p:DeployTarget=MsDeployPublish
/p:CreatePackageOnPublish=True
/p:MSDeployPublishMethod=InProc
/p:MSDeployServiceURL=localhost
/p:DeployIISAppPath="Default Web Site"

그러나 이것에 대한 문서는 어디에 있습니까-찾을 수 없습니까?

나는 이것을 작동시키기 위해 하루 종일 보냈고 그것을 올바르게 잡을 수 없으며 다양한 오류가 계속 발생합니다. 패키지 cmd파일을 실행하면 완벽하게 배포됩니다. Visual Studio를 통해 WebDeploy를 실행하면 완벽하게 작동합니다.

그러나 패키지 파일 msbuild을 별도로 호출 msdeploy하거나 실행 하지 않고 이러한 인수 사용하여 전체 배포를 실행하고 싶습니다 .cmd. 어떻게 할 수 있습니까?

추신. 네, Web Deployment Agent Service실행이 있습니다. 또한 IIS에서 실행되는 관리 서비스가 있습니다. 나는 둘 다 사용해 보았습니다.


내가 사용하는 Args :

/p:DeployOnBuild=True 
/p:DeployTarget=MsDeployPublish 
/p:Configuration=Release 
/p:CreatePackageOnPublish=True  
/p:DeployIisAppPath=staging.example.com   
/p:MsDeployServiceUrl=https://staging.example.com:8172/msdeploy.axd 
/p:AllowUntrustedCertificate=True

나에게주는 :

C : \ Program Files (x86) \ MSBuild \ Microsoft \ VisualStudio \ v10.0 \ Web \ Microsoft.Web.Publishing.targets (2660) : VsMsdeploy 실패 (원격 에이전트 (URL https://staging.example.com : 8172 / msdeploy.axd? site = staging.example.com )에 연결할 수 없습니다. 원격 에이전트 서비스가 대상 컴퓨터에 설치되고 시작되었는지 확인하십시오. 오류 세부 정보 : 원격 에이전트 (URL https : //staging.example. com : 8172 / msdeploy.axd? site = staging.example.com )에 연결할 수 없습니다. 원격 에이전트 서비스가 대상 컴퓨터에 설치되고 시작되었는지 확인하십시오. 지원되지 않는 응답이 수신되었습니다. 응답 헤더 'MSDeploy.Response'는 ''이지만 'v1'이 필요합니다. 원격 서버가 오류를 반환했습니다 : (401) Unauthorized.


IIS7 + 관련 답변 ....

좋아-여기에 내가 한 일이 있습니다. 이 스레드 / 질문에서 Simon Weaver 의 게시물을 따르십시오 .

그러나 MSBuild 설정에 관해서는 .. 여기에있는 대부분의 사람들은 다음 설정을 사용하고 있습니다. /p:MSDeployPublishMethod=RemoteAgent이는 IIS7에 적합 하지 않습니다 . 이 설정을 사용하면 TFS가 URL에 연결을 시도합니다. https://your-server-name/MSDEPLOYAGENTSERVICE하지만 해당 URL에 액세스하려면 인증 할 사용자가 관리자 여야합니다. 어느 것이 엉망입니다. (그리고 관리자 무시 규칙을 선택해야합니다). 이 URL은 IIS6 용입니다.

RemoteAgent를 사용하여 연결하려고 할 때 발생하는 표준 오류 메시지는 다음과 같습니다.

Standard 401 Frak Off u suck RemoteAgent, error

C : \ Program Files (x86) \ MSBuild \ Microsoft \ VisualStudio \ v10.0 \ Web \ Microsoft.Web.Publishing.targets (3588) : 웹 배포 작업이 실패했습니다. (원격 에이전트 (URL http : // your-web- server / MSDEPLOYAGENTSERVICE )에 연결할 수 없습니다. 원격 에이전트 서비스가 대상 컴퓨터에 설치되고 시작되었는지 확인하십시오.) 사이트 이름, 사용자 이름 및 암호가 올바른지 확인하십시오. 문제가 해결되지 않으면 로컬 또는 서버 관리자에게 문의하십시오. 오류 세부 정보 : 원격 에이전트 (URL http : // your-web-server / MSDEPLOYAGENTSERVICE)에 연락 할 수 없습니다. 원격 에이전트 서비스가 대상 컴퓨터에 설치되고 시작되었는지 확인하십시오. 지원되지 않는 응답이 수신되었습니다. 응답 헤더 'MSDeploy.Response'는 'V1'이었지만 'v1'이 필요했습니다. 원격 서버가 오류를 반환했습니다 : (401) Unauthorized.

따라서 .. 다음으로 변경해야 MSDeployPublishMethod합니다.

/p:MSDeployPublishMethod=WMSVC

WMSVCWindows Manager Service 약자입니다. 기본적으로 Remote Agent에 대한 새로운 래퍼이지만 이제 사용자 이름과 암호를 수정하여 제공 할 수 있습니다. 사용자가 관리자 일 필요는 없습니다! (기쁨!) 이제 웹 사이트별로 .. 액세스 할 사용자를 설정할 수 있습니다.

여기에 이미지 설명 입력

또한 이제 url : https://your-web-server:8172/MsDeploy.axd<-를 입력 하려고 시도합니다. 이는 Visual Studio 2010 Publish창이 수행 하는 것과 정확히 같습니다 ! (OMG-> 페니 드랍스 !! 붐!)

여기에 이미지 설명 입력

마지막 MSBuild 설정은 다음과 같습니다.

/p:DeployOnBuild=True
/p:DeployTarget=MSDeployPublish 
/p:MSDeployPublishMethod=WMSVC
/p:MsDeployServiceUrl=your-server-name
/p:DeployIISAppPath=name-of-the-website-in-iis7    
/p:username=AppianMedia\some-domain-user 
/p:password=JonSkeet<3<3<3
/p:AllowUntrustedCertificate=True

사용자 이름에 도메인 이름이 있습니다. 그게 필요합니다. 또한 내 사진에서는 도메인 사용자가 관리를 위해 웹 사이트에 액세스 할 수 있도록 허용했습니다. 따라서 내가 추가 한 새 사용자 계정 (TFSBuildService)에는 Domain Users그룹 에 대한 멤버십이 있습니다 . 그래서 모든 것이 작동합니다.

자-이 모든 것을 읽으 셨다면, lolcat을 드세요 (SOOOOOOOO 2007이기 때문에) ....

여기에 이미지 설명 입력


마침내 나를 위해 일한 단계는 다음과 같습니다. RemoteAgent로 작업하고 싶었지만 어떤 시도를하더라도 작동하지 못했습니다.

똑같이 할 필요는 없지만 이것이 내가 작동하게 한 방법입니다.

  • WMSVC 구성
  • 서비스가 시작되었는지 확인
  • IIS 사용자를 구성하고 (IIS에서 최상위 서버 이름 클릭) 'IIS 관리자 사용자'로 이동합니다. Windows 이름과 다르게 만드는 것이 좋습니다.
  • 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


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?


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.


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.


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


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...


If you can deploy your applications with fileCopy, it is easy to customize the TFS workflow to do so.

I've used the CopyDirectory activity, with the help of these articles:

http://www.ewaldhofman.nl/post/2010/11/09/Part-14-Execute-a-PowerShell-script.aspx

and

http://geekswithblogs.net/jakob/archive/2010/09/01/tfs-team-build-2010-how-to-place-the-build-output.aspx

Very simple and straightforward.

  • I Configured the build service with a user account that has write privileges on the desired share.

  • 다음으로 CopyDirectory 워크 플로 단계를 만들고 소스를 BuildDetail.DropLocation + "_PublishedWebsites"로 구성하고 대상에 대해 빌드 구성에 채울 수있는 "DeployPath"라는 인수를 만들었습니다.

  • 이제 CopyDirectory 활동을 호출하기 전에 빌드가 성공했는지 확인하는 테스트를 구현해야합니다. 내가 언급 한 기사는 그 방법을 보여줍니다. 또한 CopyDirectory 대신 powershell 스크립트를 호출하는 방법을 가르칩니다.

참고 URL : https://stackoverflow.com/questions/2636153/how-can-i-get-tfs2010-to-run-msdeploy-for-me-through-msbuild

반응형