MsDeploy 远程处理执行清单两次
我已经:
- 为 msdeploy 创建了一个清单以:
停止、卸载、复制、安装和启动 Windows 服务。 - 从清单创建了一个包
- 针对远程服务器上的包执行了 msdeploy。
问题:它执行整个清单两次。
尝试过:我修改了 waitInterval 和 waitAttempts ,认为它超时并重新开始,但这没有帮助。
问题:是什么导致它执行两次?
清单:
<sitemanifest>
<runCommand path="net stop TestSvc"
waitInterval="240000"
waitAttempts="1"/>
<runCommand
path="C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe /u
C:\msdeploy\TestSvc\TestSvc\bin\Debug\TestSvc.exe"
waitInterval="240000"
waitAttempts="1"/>
<dirPath path="C:\msdeploy\TestSvc\TestSvc\bin\Debug" />
<runCommand
path="C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe
C:\msdeploy\TestSvc\TestSvc\bin\Debug\TestSvc.exe"
waitInterval="240000"
waitAttempts="1"/>
<runCommand path="net start TestSvc"
waitInterval="240000"
waitAttempts="1"/>
</sitemanifest>
打包它所发出的命令:
"C:\Program Files\IIS\Microsoft Web Deploy V2\msdeploy"
-verb:sync
-source:manifest=c:\msdeploy\custom.xml
-dest:package=c:\msdeploy\package.zip
执行它所发出的命令:
"C:\Program Files\IIS\Microsoft Web Deploy V2\msdeploy"
-verb:sync
-source:package=c:\msdeploy\package.zip
-dest:auto,computername=<computerNameHere>
我以具有管理访问权限的域用户身份运行盒子。我也尝试过传递凭据 - 这不是权限问题,命令成功,只是执行两次。
编辑:
我启用了-verbose
并在日志中发现了一些有趣的行:
Verbose:执行同步传递#1。
...
详细:源文件路径 (C:\msdeploy\MyTestWindowsService\MyTestWindowsService\bin\Debug\MyTestWindowsService.exe) 与属性不同的目标 (C:\msdeploy\MyTestWindowsService\MyTestWindowsService\bin\Debug\MyTestWindowsService.exe) 不匹配(lastWriteTime['11/08/2011 23:40:30','11/08/2011 23:39:52'])。更新待定。
详细:源文件路径 (C:\msdeploy\MyTestWindowsService\MyTestWindowsService\bin\Debug\MyTestWindowsService.pdb) 与目标 (C:\msdeploy\MyTestWindowsService\MyTestWindowsService\bin\Debug\MyTestWindowsService.pdb) 属性 (lastWriteTime) 不同'11/08/2011 23:40:30','11/08/2011 23:39:52'])。更新待定。
在这些行之后,第一次不会复制文件,但第二次会复制
...
详细:依赖项检查“DependencyCheckInUse”没有发现问题。
详细:已收到代理的响应(HTTP 状态“正常”)。
详细:当前同步传递缺少 2 个对象的流内容。
详细:正在执行同步传递 #2。
...
高级别
通常我部署一个新构建的包,其中包含比服务器上更新的位。
在第二遍中,它会重复第一遍中完成的所有操作。
在第 1 步中,它将:
- 停止、卸载、(删除由服务安装创建的一些日志文件)、安装和启动 Windows 服务
在第 2 步中,它将:
- 停止、卸载、复制文件、安装并启动 Windows 服务。
我不知道为什么它不复制第 1 阶段中的文件,也不知道为什么触发第 2 阶段。
如果我重新部署相同的包而不是部署新的位,它将运行第 1 遍中的所有步骤,而不是运行第 2 遍。可能是因为这些文件具有相同的时间戳。
I have:
- Created a manifest for msdeploy to:
Stop, Uninstall, Copy over, Install, and Start a Windows service. - Created a package from the manifest
- Executed msdeploy against the package against a remote server.
Problem: It executes the entire manifest twice.
Tried: I have tinkered with the waitInterval and waitAttempts thinking it was timing out and starting over, but that hasn't helper.
Question: What might be making it execute twice?
The Manifest:
<sitemanifest>
<runCommand path="net stop TestSvc"
waitInterval="240000"
waitAttempts="1"/>
<runCommand
path="C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe /u
C:\msdeploy\TestSvc\TestSvc\bin\Debug\TestSvc.exe"
waitInterval="240000"
waitAttempts="1"/>
<dirPath path="C:\msdeploy\TestSvc\TestSvc\bin\Debug" />
<runCommand
path="C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe
C:\msdeploy\TestSvc\TestSvc\bin\Debug\TestSvc.exe"
waitInterval="240000"
waitAttempts="1"/>
<runCommand path="net start TestSvc"
waitInterval="240000"
waitAttempts="1"/>
</sitemanifest>
The command issued to package it:
"C:\Program Files\IIS\Microsoft Web Deploy V2\msdeploy"
-verb:sync
-source:manifest=c:\msdeploy\custom.xml
-dest:package=c:\msdeploy\package.zip
The command issued to execute it:
"C:\Program Files\IIS\Microsoft Web Deploy V2\msdeploy"
-verb:sync
-source:package=c:\msdeploy\package.zip
-dest:auto,computername=<computerNameHere>
I am running as a domain user who has administrative access on the box. I have also tried passing credentials - it is not a permissions issue, the commands are succeeding, just executing twice.
Edit:
I enabled -verbose
and found some interesting lines in the log:
Verbose: Performing synchronization pass #1.
...
Verbose: Source filePath (C:\msdeploy\MyTestWindowsService\MyTestWindowsService\bin\Debug\MyTestWindowsService.exe) does not match destination (C:\msdeploy\MyTestWindowsService\MyTestWindowsService\bin\Debug\MyTestWindowsService.exe) differing in attributes (lastWriteTime['11/08/2011 23:40:30','11/08/2011 23:39:52']). Update pending.
Verbose: Source filePath (C:\msdeploy\MyTestWindowsService\MyTestWindowsService\bin\Debug\MyTestWindowsService.pdb) does not match destination (C:\msdeploy\MyTestWindowsService\MyTestWindowsService\bin\Debug\MyTestWindowsService.pdb) differing in attributes (lastWriteTime['11/08/2011 23:40:30','11/08/2011 23:39:52']). Update pending.
After these lines, files aren't copied the first time, but are copied the second time
...
Verbose: The dependency check 'DependencyCheckInUse' found no issues.
Verbose: Received response from agent (HTTP status 'OK').
Verbose: The current synchronization pass is missing stream content for 2 objects.
Verbose: Performing synchronization pass #2.
...
High Level
Normally I deploy a freshly built package with newer bits than are on the server.
During pass two, it duplicates everything that was done in pass one.
In pass 1, it will:
- Stop, Uninstall, (delete some log files created by the service install), Install, and Start a Windows service
In pass 2, it will:
- Stop, Uninstall, Copy files over, Install, and Start a Windows service.
I have no idea why it doesn't copy over the files in pass 1, or why pass 2 is triggered.
If I redeploy the same package instead of deploying fresh bits, it will run all the steps in pass 1, and not run pass 2. Probably because the files have the same time stamp.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题中没有足够的信息来真正重现问题以给出具体的答案...但是有几件事需要检查/更改/尝试才能使其工作:
waitInterval="240000"
和waitAttempt="1"
(双引号而不是单引号)-whatif
和-verbose
选项编辑 - 添加
-verbose
输出后:我看到这些可能性:
两台机器都有时间差异(其中一台稍微有点偏差或存在时区问题......)
如果其中一个文件系统是 FAT,这可能会导致问题(时间戳解析...)
编辑 2 - 根据评论:
在我的上一次编辑中,我写了有关时间戳的内容,因为我怀疑比较这些时会出现问题...例如,两台机器之间的时钟不同(甚至 30 秒的差异也会产生影响)和/或一些时区问题......
我写过有关文件系统的文章。 FAT 因为 FAT 的时间戳分辨率约为 2 秒,而 NTFS 的分辨率要高得多,这在比较时间戳时可能会产生影响...
根据您的描述,我建议采用以下解决方法:
preSync
和postSync
服务处理部分(即用于停止 + 卸载的preSync
和用于安装 + 启动的postSync
),并且仅在清单或命令行中执行纯同步或者
runCommand<的脚本/code> 部分
编辑 3 - 根据 Merlyn Morgan-Graham 的评论,结果供将来参考:
使用
runCommand
提供程序时,请使用批处理文件。由于某种原因,这使得它停止运行两次。此解决方案的问题在于,无法通过
SetParameters.xml
文件指定服务的安装目录(对于dontUseCommandExe
/preSync
/postSync
关于SetParameters.xml
)。编辑4 - 根据 Merlyn Morgan-Graham 的评论:
超时参数适用于是否终止该特定命令,而不是关闭 Windows 服务本身......在这种情况下,Windows 服务似乎需要相当长的时间才能停止因此,只有
runCommand
会在没有复制/同步的情况下执行,并且会启动整个运行的新尝试...There is not enough information in the question to really reproduce the problem to give a specific answer... but there are several things to check/change/try to make this work:
waitInterval="240000"
andwaitAttempt="1"
(double quotes instead of single quotes)-whatif
and-verbose
optionsEDIT - after the addition of
-verbose
output:I see these possibilities:
Both machines have a difference in time (either one of them is just a bit off or some timezone issue...)
If one of the filesystems is FAT this could lead to problems (timestamp resolution...)
EDIT 2 - as per comments:
In my last EDIT I wrote about timestamp because my suspicion is that something goes wrong when these are compared... that can be for example differring clocks between both machines (even a difference of 30 sec can have an impact) and/or some timezone issues...
I wrote about filesystem esp. FAT since the timestamp resolution of FAT is someabout 2 seconds while NTFS has much higher resolution, again this could have an impact when comparing timestamps...
From what you describe I would suggest the following workarounds:
preSync
andpostSync
for the Service handling parts (i.e.preSync
for stop + uninstall andpostSync
for install + start) and do only the pure sync in the manifest or commandlineOR
runCommand
partsEDIT 3 - as per comment from Merlyn Morgan-Graham the result for future reference:
When using the
runCommand
provider, use batch files. For some reason this made it stop running two passes.The problem with this solution is that one can't specify the installation directory of the service via a
SetParameters.xml
file (same fordontUseCommandExe
/preSync
/postSync
regardingSetParameters.xml
).EDIT 4 - as per comment from Merlyn Morgan-Graham:
The timeout params apply to whether to kill that specific command, not to the closing of the Windows Service itself... in this case it seems that the Windows Service takes rather long to stop and thus only the
runCommand
s get executed without the copy/sync and a new try for the whole run is initiated...我遇到了同样的问题,但我没有制作 package.zip 文件。
我直接一步进行同步。
preSync/postSync 解决方案对我帮助很大,并且不需要使用清单文件。
您可以根据您的情况尝试以下命令:
“-verb:sync”参数表示您在源和目标之间同步数据。根据您的情况,第一次在“C:\msdeploy\TestSvc\TestSvc\bin\Debug”文件夹和“package.zip”之间执行同步。另外,您正在使用清单文件,因此当您在“package.zip”和目标“computername”之间执行第二次同步时,msbuild 会为目标和源使用之前提供的清单两次,因此每个清单操作都会运行两次。
我用了 &&在一个命令行中执行多个命令的技巧。
另外,就我而言,我必须添加超时操作以确保服务完全停止(“ping -n 30 127.0.0.1 > nul”)。
I had the same problem, but I don't make package.zip file.
I perform synchronization directly in one step.
The preSync/postSync solution helped me a lot and there is no need to use manifest files.
You can try the following command in your case:
"-verb:sync" parameter means you synchronize data between a source and a destination. In your case your case, first time you perform synchronization between the "C:\msdeploy\TestSvc\TestSvc\bin\Debug" folder and the "package.zip". Plus, you are using manifest file, so when you perform second synchronization between the "package.zip" and the destination "computername", msbuild uses previously provided manifest twice for the destination and for the source, so each manifest operation runs twice.
I used the && trick to perform several commands in one command line.
Also, in my case, I had to add timeout operation to be sure the service were completely stopped ("ping -n 30 127.0.0.1 > nul").