在VS2010中使用发布工具时如何包含被忽略的文件?
我的 asp.net mvc 项目中有一个目录 /media/fonts
,其中包含我网站的字体。当我在 Visual Studio 中使用“发布”工具时,即使该文件夹包含在我的项目中,它也会被忽略。其他文件夹 /media/images
和 /media/css
也包含在内。
有什么方法可以告诉 Visual Studio 在发布时不要忽略此文件夹吗?
I have a directory /media/fonts
in my asp.net mvc project which contains fonts for my website. When I use the "Publish" tool in Visual Studio this folder is ignored even though it is included in my project. Other folders /media/images
and /media/css
are included just fine.
Is there any way to tell Visual Studio to not ignore this folder on publish?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
选择您的字体文件并将构建操作更改为属性窗口中的内容。
Select your font files and Change Build action as Content from Properties Window.
您可以通过修改字体文件扩展名(.eot、.ttf 等)的默认构建操作来永久修复此问题
http://blog.andreloker.de/post/2010/07/02/Visual-Studio-default- build-action-for-non-default-file-types.aspx
该链接已被时间的残酷行进所暗杀,因此这里是其内容的复制/粘贴:
文件类型的默认构建操作可以在注册表中进行配置。然而,我们不是手动破解注册表,而是使用更好的方法:pkgdef 文件(一篇关于 pkgdef 文件的好文章)。本质上,pkdef 是类似于 .reg 文件的配置文件,用于定义注册表项和值,并自动合并到真实注册表中的正确位置。如果删除 pkgfile,更改将自动撤消。因此,您可以安全地修改注册表,而不会有破坏任何东西的危险 - 或者至少,很容易消除损坏。
最后,这里是如何更改文件类型的默认构建操作的示例:
键中的 Guid 指的是项目类型。在本例中,
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
表示“C# 项目”。可以找到相当全面的项目类型 GUID 列表 这里。尽管它没有明确涵盖 Visual Studio 2010,但指南也适用于当前版本。顺便说一下,这里我们可以使用C#作为项目类型,因为基于C#的MVC项目实际上是C#项目(以及Web应用程序项目)。对于 Visual Basic,您可以使用{F184B08F-C81C-45F6-A57F-5ABD9991F28F}
。$RootKey$
是 Visual Studio 存储配置的真实注册表项的抽象:(注意:不要尝试手动编辑此项下的任何内容,因为 Visual Studio 可以随时覆盖它)。
其余内容应该是不言自明的:此选项将
.spark
文件的默认构建操作设置为“Content”,因此这些文件包含在发布过程中。现在您需要做的就是将这段文本放入扩展名为 pkgdef 的文件中,将其放在
(在 64 位系统上)或
(在 32 位系统上)下的某个位置,Visual Studio 将自动加载并应用设置下次启动时。要撤消更改,只需删除文件即可。
You can fix this permanently by modifying the default Build Action for font file extensions (.eot, .ttf, etc)
http://blog.andreloker.de/post/2010/07/02/Visual-Studio-default-build-action-for-non-default-file-types.aspx
The link has been assassinated by the cruel march of time, so here's a copy/paste of its contents:
The default build action of a file type can be configured in the registry. However, instead of hacking the registry manually, we use a much better approach: pkgdef files (a good article about pkgdef files). In essence, pkdef are configuration files similar to .reg files that define registry keys and values that are automatically merged into the correct location in the real registry. If the pkgfile is removed, the changes are automatically undone. Thus, you can safely modify the registry without the danger of breaking anything – or at least, it’s easy to undo the damage.
Finally, here’s an example of how to change the default build action of a file type:
The Guid in the key refers to project type. In this case,
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
means “C# projects”. A rather comprehensive list of project type guids can be found here. Although it does not cover Visual Studio 2010 explicitly, the Guids apply to the current version as well. By the way, we can use C# as the project type here, because C# based MVC projects are in fact C# projects (and web application projects). For Visual Basic, you’d use{F184B08F-C81C-45F6-A57F-5ABD9991F28F}
instead.$RootKey$
is an abstraction of the real registry key that Visual Studio stores the configuration under:(Note: Do not try to manually edit anything under this key as it can be overwritten at any time by Visual Studio).
The rest should be self explanatory: this option sets the default build action of
.spark
files to “Content”, so those files are included in the publishing process.All you need to do now is to put this piece of text into a file with the extension pkgdef, put it somewhere under
(on 64-bit systems) or
(on 32-bit systems) and Visual Studio will load and apply the settings automatically the next time it starts. To undo the changes, simply remove the files.
Visual Studio 确实发布字体文件。在特殊情况下,我们将扩展名从
.ttf
重命名为.jpg
并发布。Visual Studio does publish font files. In a special case we renamed extensions from
.ttf
to.jpg
and they got published.