是否可以过滤 Web 设置项目的 ContentFiles 子文件夹中的文件?

发布于 2025-01-02 19:29:23 字数 375 浏览 0 评论 0原文

我有一个网络设置项目和一个网站包含在同一解决方案中。 在设置项目中,我添加了指向网站内容的内容文件

在此网站中,有一些文件夹包含动态生成的文件(即.log 文件、一些图像文件等),我不希望这些文件包含在安装程序中。我尝试添加过滤器 Symbols\*.png 但这不起作用。我还尝试了一个名为 *.png 的过滤器,这排除了该文件夹中的 .png 文件,但问题是它也排除了网站中必须存在的所有静态 .png 文件。

如何添加一个过滤器,仅排除我想要的目录下的文件?

删除文件后是否可以在 PreBuildEvent 中调用某些内容来告诉 VS 刷新网站内容?

还有其他方法可以解决这个问题吗?

I have a web setup project and a web site included in the same sollution.
In the setup project, I have added Content files pointing to the web site content.

In this web site there are some folders that contains dynamically generated files (i.e .log files, some image files etc.) I do not want these files to be included in the setup. I have tried to add a filter Symbols\*.png but this does not work. I have also tried a filter called *.png, and this excludes the .png files within that folder, but the problem is it also excludes all static .png files in the web site that must be there.

How can I add a filter that excludes only the files under the directory I want?

Is it possible to call something in the PreBuildEvent after the files are deleted that will tell VS to refresh the web site content?

Are there any other approaches that can solve this?

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

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

发布评论

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

评论(2

巨坚强 2025-01-09 19:29:23

您是否尝试过使用记事本编辑 .csproj 文件并添加类似内容:

<ItemGroup>
  <!-- This will exclude the .png files from the Symbols folder -->    
  <ExcludeFromPackageFiles Include="$(ProjectDir)..\..\MyWebSite\Symbols\*.png" />   
</ItemGroup>

其中 ItemGroup 在以下行之后:

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />

您可以在以下文章中找到更多信息:http://sedodream.com/2010/05/01/WebDeploymentToolMSDeployBuildPackageInclusionExtraFilesOrExducingSpecificFiles.aspx

Have you tried to edit your .csproj file with notepad and add something like:

<ItemGroup>
  <!-- This will exclude the .png files from the Symbols folder -->    
  <ExcludeFromPackageFiles Include="$(ProjectDir)..\..\MyWebSite\Symbols\*.png" />   
</ItemGroup>

where ItemGroup is after the following line:

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />

More info you can find in the following article: http://sedodream.com/2010/05/01/WebDeploymentToolMSDeployBuildPackageIncludingExtraFilesOrExcludingSpecificFiles.aspx

赠意 2025-01-09 19:29:23

作为一种解决方法,我创建了一个 PreBuildEvent 来删除所有不应包含在设置中的文件:

del /Q $(ProjectDir)..\..\MyWebSite\Symbols\*.png

这实际上会在我开始构建时删除这些文件,但会在稍后的构建中导致错误,因为安装内容认为应该存在的某些内容文件不存在。已删除的文件仍会在 VS 中作为网站内容进行引用。如果我浏览网站中的文件夹,我会看到已删除的文件位于 VS GUI 中(尽管文件实际上已被删除)。我必须对网站项目进行刷新以告诉VS内容已更改,然后再次进行构建。然后它就可以工作了,我的设置包含了我想要的内容。

As a workaround, I have created a PreBuildEvent that deletes all the files that should not be included in the setup:

del /Q $(ProjectDir)..\..\MyWebSite\Symbols\*.png

This actually deletes the files when I start the build, but it causes an error later in the build, because some content files does not exist that the setup content thinks should be there. The files that are deleted, are still referenced in VS as content in the web site. If I browse the folders in the web site, I see that the deleted files are there in the VS GUI (although the files are actually deleted). I have to do a refresh on the web site project to tell VS that the content has changed, and then do the build again. Then it works, and my setup contains what I want.

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