TFS msbuild args /p:DeployOnBuild=true似乎没有任何作用

时间:2022-09-11 16:35:10

I'm currently using TFS and the regular build process activity to build a solution. However, I'd like to be able to automate deployment so I can build and deploy remotely to a server in one step.

我目前正在使用TFS和常规的构建过程活动来构建解决方案。但是,我希望能够自动部署,这样我就可以在一个步骤中构建并远程部署到服务器。

On the MSBuild arguments I am trying to specify the deployment switch. My project is a windows service, but I understand it is still possible to deploy any binaries regardless of the project type (not being a web project).

在MSBuild参数上,我试图指定部署开关。我的项目是一个windows服务,但是我知道仍然可以部署任何二进制文件,而不考虑项目类型(不是web项目)。

Current build parameters:

当前构建参数:

/p:DeployOnBuild=True /p:UserName=user /p:Password=password

When the build runs in TFS it succeeds, however I was expecting to see some attempt at deployment to the server and some helpful error message but nothing shows.

当构建在TFS中运行时,它成功了,但是我希望看到一些部署到服务器的尝试和一些有用的错误消息,但是没有显示任何内容。

2 个解决方案

#1


22  

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.

为了以后的参考,我已经确切地找到了为web服务/项目以外的任何东西启用部署所需的内容。DeployOnBuild参数除了用于web项目之外什么都不做的原因是项目文件需要包含webapplication。目标和包含到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:

这里的链接很好地介绍了web部署是如何工作的,以及如何将其集成到我的项目中来部署服务:

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

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.

要将参数传递给MSBuild,您需要在项目属性文件夹下的PublishProfiles文件夹中创建.pubxml文件(称为发布配置文件)。

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

2) .csproj文件中需要以下内容:

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

3)如果您需要MSDeploy的预同步/后同步命令,不幸的是,MSBuild不能提供这个命令。要实现这个功能,您需要有一个X.Wpp。目标(X是您的项目名称)在您的项目根文件夹中。

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

#2


-1  

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

您需要一种使用MSBuild部署Windows服务的方法。试试这个方法http://mrchief.calepin.co/deploying-windows-service-via-msbuild/

#1


22  

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.

为了以后的参考,我已经确切地找到了为web服务/项目以外的任何东西启用部署所需的内容。DeployOnBuild参数除了用于web项目之外什么都不做的原因是项目文件需要包含webapplication。目标和包含到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:

这里的链接很好地介绍了web部署是如何工作的,以及如何将其集成到我的项目中来部署服务:

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

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.

要将参数传递给MSBuild,您需要在项目属性文件夹下的PublishProfiles文件夹中创建.pubxml文件(称为发布配置文件)。

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

2) .csproj文件中需要以下内容:

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

3)如果您需要MSDeploy的预同步/后同步命令,不幸的是,MSBuild不能提供这个命令。要实现这个功能,您需要有一个X.Wpp。目标(X是您的项目名称)在您的项目根文件夹中。

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

#2


-1  

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

您需要一种使用MSBuild部署Windows服务的方法。试试这个方法http://mrchief.calepin.co/deploying-windows-service-via-msbuild/