Question

I'm running into a scenario where I need to replace some files in my project during publishing with other custom files. The case is we have several websites that uses the same code base. However, some websites needs a customized version of the deployed files (e.g. favicon.ico, Error.aspx…).

I have been trying to include these files as “extra files” in my projectName.wpp.targets as mentioned Here in Sayed Ibrahim Hashimi blog but they get overwritten by the original project files during publishing.

I can see from the publishing output that the "extra files" are being included in the package but then they are being replaced by the same files from the project.

Is there a way to tell MS Deploy to include my files after the project content files are included such that my files overwrite?

------------Update------------------

I found out from the below log (thanks to David Martin comment) that the files are not being overwritten but rather they are being skipped because the files in the project are newer than what I am trying to include:

CopyPipelineFiles: Skip copying F:\Extra Files For Sites Deployment\xxx\favicon.ico to obj\xxx\Package\PackageTmp\favicon.ico, File obj\xxx\Package\PackageTmp\favicon.ico is up to date

So is there a way to force including these files even if they are older into the package?

Was it helpful?

Solution

OK, so I have found a fix for this and will post here if someone else ran to this issue but I welcome any other solutions!

The problem as stated in my question is caused by the files I want to include in my package being older than the files in my project. So I needed to find a way to update the last modified date.

I found out that there is a "Touch" task that will do exactly that: http://msdn.microsoft.com/en-us/library/37fwbyt5.aspx

So this is what I finally did in my script:

  <ItemGroup>
    <Files Include="F:\Files For Sites Deployment\xxx\**\*" />
  </ItemGroup>

  <PropertyGroup>
    <CopyAllFilesToSingleFolderForMsdeployDependsOn>
      TouchIncludeFiles;
      CustomCollectFiles;
      $(CopyAllFilesToSingleFolderForMsdeployDependsOn);
      </CopyAllFilesToSingleFolderForMsdeployDependsOn>
  </PropertyGroup>

  <Target Name="TouchIncludeFiles">
    <Touch Files="@(Files)" ForceTouch="true"></Touch>
  </Target>
  <Target Name="CustomCollectFiles">
    <ItemGroup>
      <_CustomFiles Include="@(Files)" />
      <FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
        <DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
      </FilesForPackagingFromProject>
    </ItemGroup>
  </Target>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top