msbuild 文件更新安装项目

发布于 2024-08-17 18:56:29 字数 670 浏览 4 评论 0原文

我希望使用 msbuildtasks.tigris.org 中的 fileUpdate 任务来修改图像 src,作为我们 Web 设置项目的一部分,以便它们指向静态 img 子域(或稍后的 CDN)
我可以使用以下命令在给定项目中运行任务:

<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 的部署项目的一部分来运行。 这是使用 Web 安装项目 (.vdproj) 完成的,该项目还使用自定义操作项目,该项目只是标准 .csproj

我的问题是:

  1. 如何在安装项目中运行此任务,以便替换文件中的内容进入.msi?
  2. 有没有办法对文件使用通配符 - 理想情况下我想说对所有 .css 文件都这样做?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ゃ人海孤独症 2024-08-24 18:56:29

为了实现这一点,您需要使用项目组来为您创建列表

<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>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文