0
votes

While creating deployment project for my solution strange behavior have been noticed. I'm using webdeploy for deployment of my web apps. And when putting this

<Exec Command="$(MsBuildBinPath)\msbuild.exe     $(SourceControlPath)\...\myproject.csproj /p:configuration=Release /p:DeployOnBuild=True /p:DeployTarget=MSDeployPublish /p:MSDeployServiceUrl=https://x.x.x.x:8172/msdeploy.axd /p:MSDeployPublishMethod=WMSvc /p:DeployIisAppPath=&quot;Default Web Site&quot; /p:username=username /p:password=password /p:AllowUntrustedCertificate=True /P:CreatePackageOnPublish=True">
</Exec>

in my deploy project file, it builds and deploys my application without issues.

But using MSBuild task with exact same set of properties

    <MSBuild Properties="Configuration=$(Configuration);DeployOnBuild=True;
             DeployTarget=MSDeployPublish;MSDeployServiceUrl=https://x.x.x.x:8172/msdeploy.axd;
             MSDeployPublishMethod=WMSvc;DeployIisAppPath=&quot;Default Web Site&quot;;
             UserName=username;Password=password;
             AllowUntrustedCertificate=True;CreatePackageOnPublish=True"
            Projects="$(SourceControlPath)\...\myproject.csproj"
    ></MSBuild>

gives me an error: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.5\Web\Microsoft.Web.Publishing.targets(4196, 5): error ERROR_COULD_NOT_CONNECT_TO_REMOTESVC: Web deployment task failed. (Could not connect to the remote computer ("x.x.x.x") using the specified process ("Web Management Service") because the server did not respond. Make sure that the process ("Web Management Service") is started on the remote computer...

So, I was thinking that basically both approaches do the same. what's wrong with 2-nd approach?

1

1 Answers

0
votes

The problem may be the escaped quote you have the Properties attribute. Have you tried not including the &quot; around Default Web Site?

One way I have used to make the file more readable is pass the arguments via an item group.

<ItemGroup>
    <DeployArgs Include="Configuration=$(Configuration)" />
    <DeployArgs Include="DeployOnBuild=True" />
    <DeployArgs Include="DeployTarget=MSDeployPublish" />
    <DeployArgs Include="MSDeployServiceUrl=https://x.x.x.x:8172/msdeploy.axd" />
    <DeployArgs Include="MSDeployPublishMethod=WMSvc" />
    <DeployArgs Include="DeployIisAppPath=Default Web Site" />
    <DeployArgs Include="UserName=username" />
    <DeployArgs Include="Password=password" />
    <DeployArgs Include="AllowUntrustedCertificate=True" />
    <DeployArgs Include="CreatePackageOnPublish=True" />
 </ItemGroup>
 <MSBuild Properties="@(DeployArgs)"
          Projects="$(SourceControlPath)\...\myproject.csproj" 
 />