msbuild文件更新安装项目

问题描述:

我希望使用msbuildtasks.tigris.org中的fileUpdate任务来修改图像src,这是我们的Web安装项目的一部分,以便它们将指向静态img子域(或更高版本的CDN).
我可以使用以下命令在给定项目中运行任务:

I'm looking to use the fileUpdate task from msbuildtasks.tigris.org to modify image src's as part of our web setup project so that they will point to a static img sub domain (or later a CDN)
I can run a task within a given project with:

<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />
<Target Name="AfterBuild">
<FileUpdate 
   Files="basic.css" 
   Regex="/images/([^\)]*)" 
   ReplacementText="http://img.domain.com/images/$1" />
</Target>

但是,我不想覆盖原始的CSS源文件,但是希望将其作为产生msi的部署项目的一部分来运行. 这是通过网络设置项目(.vdproj)完成的,该项目还使用了仅是标准.csproj

However, I dont want to overwrite the original css source file, but want to run this as part of our deployment project that produces an msi. This is done using a web setup project (.vdproj) which also uses a custom actions project which is just a standard .csproj

我的问题是:

  1. 如何在安装项目中运行此任务,以便替换.msi文件中的内容?
  2. 是否可以对文件使用通配符-理想情况下,我想对所有.css文件使用通配符?

要实现此目的,您需要使用项目组来为您创建列表

In order to achieve this you need to use an item group to create the list for you

<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" /> 
<Target Name="AfterBuild"> 

<ItemGroup>
   <CssFiles Include='$(SolutionRoot)\**\*.css' />
</ItemGroup>

<FileUpdate  
   Files="@(CssFiles)"  
   Regex="/images/([^\)]*)"  
   ReplacementText="http://img.domain.com/images/$1" /> 
</Target>