TFS msbuild args/p:DeployOnBuild=true 似乎没有做任何事情 [英] TFS msbuild args /p:DeployOnBuild=true doesn't seem to do anything
问题描述
我目前正在使用 TFS 和常规构建流程活动来构建解决方案.但是,我希望能够自动部署,以便我可以一步构建并远程部署到服务器.
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.
在 MSBuild 参数上,我试图指定部署开关.我的项目是 Windows 服务,但我知道无论项目类型如何(不是网络项目),仍然可以部署任何二进制文件.
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).
当前构建参数:
/p:DeployOnBuild=True /p:UserName=user /p:Password=password
当构建在 TFS 中运行时它会成功,但是我希望看到一些部署到服务器的尝试和一些有用的错误消息,但没有显示.
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.
推荐答案
为了将来参考,我已经找到了为 Web 服务/项目以外的任何事物启用部署所需的确切条件.DeployOnBuild 参数对 Web 项目以外的任何事情都不做任何事情的原因是项目文件需要包含 webapplication.targets 和一个 PropertyGroup 包含 VSToolsPath 的路径.
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 部署的工作原理以及如何将其集成到我的项目中以部署服务:
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:
要将参数传递到 MSBuild,您需要在项目属性文件夹下的 PublishProfiles 文件夹内有一个 .pubxml 文件(称为发布配置文件).
To pass parameters into MSBuild you need a .pubxml file (called the publishing profile) within the PublishProfiles folder under your project properties folder.
我需要 .csproj 文件中的以下内容:
I needed the following in the .csproj file:
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">11.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)MicrosoftVisualStudiov$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(MSBuildToolsPath)Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)WebApplicationsMicrosoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)MicrosoftVisualStudiov11.0WebApplicationsMicrosoft.WebApplication.targets" Condition="false" />
如果您需要 MSDeploy 的同步前/同步后命令,很遗憾,这在 MSBuild 中不可用.要实现此功能,您需要在项目根文件夹中有一个 X.Wpp.Targets(其中 X 是您的项目名称).
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>
这篇关于TFS msbuild args/p:DeployOnBuild=true 似乎没有做任何事情的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!