sirdank sirdank - 1 year ago 171
C# Question

Visual studio web deploy deleting dlls during release publish

I've got the following nant script that does the build and deploy:

<msbuild project=".\Code\Code.sln" target="Build">
<property name="Configuration" value="${Build.Configuration}" />
<property name="Platform" value="${build.platform}" />
<property name="CreatePackageOnPublish" value="true" />
<property name="DeployOnBuild" value="true" />
<property name="DeployIISAppPath" value="Default Web Site\${Web.Path}" />

<exec program=".\Code\CodeWeb\obj\${Build.Configuration}\Package\CodeWeb.deploy.cmd" commandline="/y / /u:DOMAIN\user /p:password"/>

My problem is this: when I deploy in Debug or RC build configurations, everything works fine. All files are present in the publish directory and the code is updated. However, when I deploy in release configuration, the publish process deletes three .dlls that I need for my site to function.

This same code is building and publishing for all build configurations so I don't think it could be the issue. Also, I don't know if any of my publish profiles are the source of the problem but, if they are, the only appreciable differences are that Production.pubxml.user contains an
element with a whole bunch of
child elements listing out files where Development.pubxml.user doesn't contain any of that. However, I copied the
from Production.pubxml.user into Development.pubxml.user and it didn't break the Development publish process.

My msdeploy.exe log starts like this for the production publish

SetParameters from:
You can change IIS Application Name, Physical path, connectionString
or other deploy parameters in the above file.
Start executing msdeploy.exe
"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -source:package='C:\Shared\Code\CodeWeb\obj\Release\Package\' -dest:auto,computerName="",userName="DOMAIN\user",password="password",includeAcls="False" -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile:"C:\Shared\Code\CodeWeb\obj\Release\Package\CodeWeb.SetParameters.xml"
Info: Using ID '52641dbe-b1e5-4ff5-9962-01386a7fe513' for connections to the remote server.
Info: Deleting file (Default Web Site\CodeStaging\bin\System.Net.Http.Formatting.dll).
Info: Deleting file (Default Web Site\CodeStaging\bin\System.Web.Http.dll).
Info: Deleting file (Default Web Site\CodeStaging\bin\System.Web.Http.WebHost.dll).

In the dev publish, it just doesn't delete these files. I've diffed the .deploy.cmd files msbuild produces as well as done folder-level compares on the .zip packages the .deploy.cmd files deploy but I can't seem to find any differences worth speaking of.

Upon further investigation, the files are only deleted when I build the msdeploy package from my production machine. If I check out trunk/ on both my production and Dev machines and run the build and deploy code below, deploying to any environment from the Dev machine works correctly and deploying to any environment from the production machine deletes my needed assemblies. Are there some global msdeploy settings somewhere that are messed up? Also, if you are able to answer this question, perhaps take a look at my other, similar one.

Can anyone explain why the same code breaks my deploy if run from my production machine but works fine if run from my dev machine, regardless of the environment into which I am deploying?

Answer Source

I'm not entirely sure why this worked as the missing assemblies are not in the GAC on the failing machine but adding


under each of the references to these missing assemblies in my .csproj file has fixed it. References now look like this:

<Reference Include="System.Net.Http.Formatting, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">

Courtesy of

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download