【发布时间】:2014-12-23 19:00:28
【问题描述】:
之前我使用 msbuild.exe 构建和部署 Web 项目
现在我想在部署前修改一些文件,所以我使用msbuild制作了一个.zip包,然后解压缩,修改一些文件,然后再次压缩并尝试使用msdeploy进行部署。
问题在于,它部署了空文件夹。当我尝试部署未修改的 .zip 包时 - 它工作正常。
经过长时间的挖掘,我发现 msdeploy 不支持使用内置 Windows zip 存档器以外的其他方式压缩的包。
如何在 C#/F# 中使用 windows zip archiver 压缩文件?我试过使用System.IO.Compression.ZipFile.CreateFromDirectory 方法,但 msdeploy 仍然部署空文件夹。
这是我在尝试部署包时收到的警告:
Warning: Skipping source dirPath (C:\TeamCity\buildAgent\MyPath) because of rule SkipInvalidSource.
The Zip package 'C:\TeamCity\buildAgent\MyPath\MyPackage.zip' could not be loaded.
当我禁用SkipInvalidSource 规则时,我收到以下错误:
Error: (12/23/2014 6:56:44 PM) An error occurred when the request was processed on the remote computer.
Error: Object reference not set to an instance of an object.
at Microsoft.Web.Deployment.DeploymentSyncEnumerable.<Create>d__0.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildrenNoOrder(DeploymentObject dest, DeploymentObject source)
at Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildrenNoOrder(DeploymentObject dest, DeploymentObject source)
at Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildrenOrder(DeploymentObject dest, DeploymentObject source)
at Microsoft.Web.Deployment.DeploymentSyncContext.ProcessSync(DeploymentObject destinationObject, DeploymentObject sourceObject)
at Microsoft.Web.Deployment.DeploymentObject.SyncToInternal(DeploymentObject destObject, DeploymentSyncOptions syncOptions, PayloadTable payloadTable, ContentRootTable contentRootTable, Nullable`1 syncPassId, String syncSessionId) at Microsoft.Web.Deployment.DeploymentAgent.HandleSync(DeploymentAgentAsyncData asyncData, Nullable`1 passId)
Error count: 1.
知道如何正确压缩和部署项目吗?
【问题讨论】:
-
我也有同样的问题
-
@FredericTorres 我最终使用
-dest:contentPath而不是压缩包部署了整个目录。
标签: c# msbuild zip web-deployment msdeploy