如何通过MSBuild参数调用MSBuild.ExtensionPack?
您好,我正在使用MSBuild扩展包将windows服务安装到远程计算机。我通过命令提示符对此进行了测试,它成功地安装了服务。现在我想使用MSBuild参数调用此扩展包 我的代码如下所示:如何通过MSBuild参数调用MSBuild.ExtensionPack?,msbuild,windows-services,msbuildextensionpack,Msbuild,Windows Services,Msbuildextensionpack,您好,我正在使用MSBuild扩展包将windows服务安装到远程计算机。我通过命令提示符对此进行了测试,它成功地安装了服务。现在我想使用MSBuild参数调用此扩展包 我的代码如下所示: <Project ToolsVersion="4.0" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Remot
<Project ToolsVersion="4.0" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<RemoteMachine>DevRemote</RemoteMachine>
<RemoteUser>RemoteDomain\RemoteUser</RemoteUser>
<RemoteUserPassword>RemotePassword</RemoteUserPassword>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks"/>
<Target Name="Default">
<MSBuild.ExtensionPack.Computer.WindowsService TaskAction="Install" ServiceName="Backup Management" ServicePath="c:\WINDOWS\system32\taskmgr.exe" RemoteUser="$(RemoteUser)" RemoteUserPassword="$(RemoteUserPassword)" MachineName="$(RemoteMachine)" />
</Target>
/p:DeployOnBuild=True /p:DeployWinService=true;TargetWinServiceHost=DevRemote
但我不确定这些论点。非常感谢您的帮助 我通常有两个文件,一个带有属性,另一个带有目标。我还尝试将所有需要的属性存储在一个文件中,因此不需要从命令行传递任何内容 如果使用targets
main.msbuild
调用该文件,则可以这样调用它
msbuild main.msbuild /t:Default
其中,/t
开关对应于目标名称,这就是您可以指定要执行的目标的方式,因此不需要带有/p
的参数
从中,这是默认目标的外观
<Target Name="Default">
<!-- Install a service on a Remote Machine -->
<MSBuild.ExtensionPack.Computer.WindowsService
TaskAction="Install"
ServiceName="__TestService1"
User="$(User)"
Password="$(password)"
ServicePath="c:\WINDOWS\system32\taskmgr.exe"
RemoteUser="$(RemoteUser)"
RemoteUserPassword="$(RemoteUserPassword)"
MachineName="$(RemoteMachine)" />
</Target>