10

Earlier I was building and deploying web project using msbuild.exe

Now I want to modify some files before deploying, so I make a .zip package using msbuild, then unzip it, modify some files and then zip it again and try to deploy using msdeploy.

The problem is, that it deploys empty folder. When I try to deploy unmodified .zip package - it works fine.

After long hours digging, I figured out, that msdeploy does not support packages, which were zipped using other than built in windows zip archiver.

How to zip files using windows zip archiver in C#/F#? I've tried using System.IO.Compression.ZipFile.CreateFromDirectory method, but msdeploy still deploys empty folders.

Here's the warning what I get, when trying to deploy package:

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.

When I disable SkipInvalidSource rule, I get the following error:

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.

Any ideas how to zip and deploy project correctly?

1
  • 1
    @FredericTorres I ended up deploying whole directory using -dest:contentPath rather than zipped package.
    – user4228370
    Mar 23, 2015 at 16:22

3 Answers 3

11

I had this exact problem. I've got a bunch of msdeploy packages and need to update some of the files post-packaging but pre-deploy.

If I use msdeploy sync to extract the packages, the parameters get processed - that's no good, they're just placeholders until I know which environment is being targeted. So I need to unzip the package and then make the changes...so far so good.

But then I rezip it all up. And then then I get this issue: msdeploy won't process the contained folders. If I use msdeploy to process the extracted files, again I lose the parameters...or rather they get processed prematurely from the paramters.xml file. Grr.

The solution? Use 7zip...or anything apart from standard Windows zipper.

e.g. 7z.exe a -r C:\deploys\mypackage.zip C:\extractedstuff\*

1
  • 1
    Note the subtle difference in the example of using * (a single asterisk and NOT asterisk dot asterisk)! At least when using 7za.exe instead of 7z.exe, you need to use * (and not asterisk dot asterisk) or else the created archive will not work with msdeploy, apparently due to some missing directory flags, though the archive seems identical on the surface.
    – tholesen
    Aug 17, 2017 at 8:22
2

Don't use zip archiver. You must call msdeploy.exe.

bat-file example :

msdeploy.exe -verb:sync ^
-source:archiveDir="C:\YourAbsolutePathToTheFolderContaining_Content_DirAnd_XMLs" ^
-dest:package="ArchName.zip" ^
-declareParam:name="IIS Web Application Name",defaultValue="Default Web Site/AppName",tags="IisApp" ^
-declareParam:name="IIS Web Application Name",type="ProviderPath",scope="IisApp",match="^.*PackageTmp$" ^
-declareParam:name="IIS Web Application Name",type="ProviderPath",scope="setAcl",match="^.*PackageTmp$"

For more info look at help:

msdeploy -help -dest
msdeploy -help -declareParam

and other. Also, see parameters.xml

0

Dan Kendall's answer helped me but in the end I didn't need to use 7Zip. I prefer this way because then I don't need to install 7Zip on the build server.

The answer was simple, I just switched from using Zip to Archive Files

enter image description here

1

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.