9
votes

I am having trouble running a Team Foundation 2013 build with MS Build parameters for deployment and I am getting an error :

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets (4255): Web deployment task failed. ('Microsoft.Web.Deployment.DeploymentBaseOptions' does not contain a definition for 'UserAgent')

Development is being done in VS 2013.

What is strange is that if I copy the MSBuild folder *..\v11.0\Web* to the *v12.0\Web* The build works and does the deployment.

I have already checked the v12.0\Web\Microsoft.Web.Publishing.targets file and there is an entry for UserAgent while in the v11.0\Web\Microsoft.Web.Publishing.targets there is no entry

I am able to publish fine using VS Publish on my computer , but on the build server it fails Has anyone managed to build and deploy using MSBuild VS 2013 targets successfully?

2

2 Answers

13
votes

I faced the same issue. For me the solution was to install Web Deploy 3.5 (http://www.iis.net/downloads/microsoft/web-deploy). After that the error disappeared.

0
votes

I am posting this in Oct 2019. Almost 6 years after the original post on this thread, the error still occurs, but this time on VS 2019. After looking around the web and being unable to fix it even after reinstalling Deploy 3.5/3.6 and also after updating VS, I finally managed to fix it by poking around MSBuild settings. Wanted to share it here, as this is the top search result on Google.

Steps:

Created a simple command prompt application on VS 2019. Right-clicked on the project in Solution Explorer, clicked on "Publish as Azure Webjob...", and made my Azure settings in the ensuing dialog.

Expected Result:

This simple console app would be published to Azure as a WebJob, as it always did on VS 2017.

Actual Result:

The publish operation failed with the following message:

Error : Web deployment task failed. ('Microsoft.Web.Deployment.DeploymentBaseOptions' does not contain a definition for 'UserAgent') Publish failed to deploy.

Investigation:

The error line in the Output pane in Visual Studio was pointing to the file Microsoft.Web.Publishing.targets under "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\v16.0\Web". Double-clicking on this error line opened up the file at a location showing the section <VSMSDeploy>. In this section, the UserAgent property was set to "$(_MSDeployUserAgent)". _MSDeployUserAgent was in turn set up under <PropertyGroup> as <_MSDeployUserAgent>VS$(_MSDeployUserAgentSource)</_MSDeployUserAgent>. The entire PropertyGroup section is pasted below for reference:

<!-- UserAgent string sent to msdeploy -->
<PropertyGroup>
    <_MSDeployUserAgentSource Condition=" '$(BuildingInsideVisualStudio)' != 'true'">$(VisualStudioVersion):CmdLine</_MSDeployUserAgentSource>
    <_MSDeployUserAgentSource Condition=" '$(BuildingInsideVisualStudio)' == 'true'">$(VisualStudioVersion):PublishDialog</_MSDeployUserAgentSource>
    <_MSDeployUserAgent>VS$(_MSDeployUserAgentSource)</_MSDeployUserAgent>
</PropertyGroup>

The Fix:

Changing UserAgent= "$(_MSDeployUserAgent)" in the <VSMSDeploy> element to UserAgent="VS$(_MSDeployUserAgentSource)" fixed the issue, and the WebJob was successfully published to my App Service.

(WARNING: Please exercise the greatest caution when modifying this file, as an incorrect change will adversely impact ALL build commands from within VS and from the command prompt.)

Concluding Observation:

After making this change to Microsoft.Web.Publishing.targets, VS seems to have proceeded with UserAgent settings akin to a CommandLine build, without distinguishing it from a PublicDialog build. All Publish-related output lines were shown in the Output pane as they used to in VS 2017, and everything went well.