TFS msbuild args /p:DeployOnBuild=true doesn't seem to do anything

烈酒焚心 提交于 2019-11-28 18:26:42
jaffa

For future reference, I've found exactly what is required to enable deployments for anything other than web services/projects. The reason the DeployOnBuild parameter doesn't do anything for anything other than web projects is that the project file needs to include the webapplication.targets and also a PropertyGroup containing the path to the VSToolsPath.

This link here gave me a good introduction as to how web deployments work and how to integrate this into my project to deploy services:

http://www.asp.net/web-forms/tutorials/deployment/web-deployment-in-the-enterprise/building-and-packaging-web-application-projects

  1. To pass parameters into MSBuild you need a .pubxml file (called the publishing profile) within the PublishProfiles folder under your project properties folder.

  2. I needed the following in the .csproj file:

    <PropertyGroup>
        <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">11.0</VisualStudioVersion>
        <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
      </PropertyGroup>
    
      <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
      <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
      <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
    
  3. If you need the pre-sync/post-sync commands of MSDeploy, unfortunately this is not available from MSBuild. To do achieve this functionality you need to have a X.Wpp.Targets (where X is your project name) inside your project root folder.

    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <Target Name="UninstallService" BeforeTargets="MSDeployPublish">    
          <!-- Do exec tasks here -->
      </Target>
    
      <Target Name="InstallService" AfterTargets="MSDeployPublish">    
          <!-- Do exec tasks here -->            
      </Target>
    </Project>
    

you need a way to deploy the Windows services using MSBuild. Try this Method http://mrchief.calepin.co/deploying-windows-service-via-msbuild/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!