msbuild fileupdate setup project

核能气质少年 提交于 2019-12-06 11:56:26

问题


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>

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

My questions are:

  1. How can I run this task in the setup project so that I replace content in the files that go into the .msi?
  2. Is there a way to use wildcards for the files - ideally I want to say do this for ALL .css files?

回答1:


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>


来源:https://stackoverflow.com/questions/2020192/msbuild-fileupdate-setup-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!