Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

msbuild fileupdate setup project

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?
like image 779
steve Avatar asked Mar 28 '26 22:03

steve


1 Answers

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>
like image 145
krystan honour Avatar answered Apr 02 '26 20:04

krystan honour



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!