每次我将 xsd 文件添加到我的 Visual Studio 2008 构建项目时,它的构建操作默认为无".我经常忘记把这个放到内容"中,这会打乱构建......
是否可以将 xsd 文件的默认构建操作设置为内容"?
终于在另一个stackoverflow问题:
http://blog.andreloker.de/post/2010/07/02/Visual-Studio-default-build-action-for-non-default-file-types.aspxp><小时>
来自文章:
<块引用>更改文件类型的默认构建操作 默认构建可以在注册表中配置文件类型的操作.然而,而不是手动破解注册表,我们使用更好的方法:pkgdef 文件(一篇关于 pkgdef 文件的好文章).在本质上,pkdef 是类似于 .reg 文件的配置文件定义自动合并到真实注册表中的正确位置.如果删除了 pkgfile,则更改会自动撤消.因此,您可以安全地修改注册表没有破坏任何东西的危险——或者至少,它是很容易消除损坏.
最后,这是一个如何更改默认构建操作的示例文件类型:
1:[$RootKey$Projects{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}FileExtensions.spark]2: "DefaultBuildAction"="Content" 键中的Guid指的是项目类型.在这种情况下,{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"表示C# 项目".一个相当全面的项目类型指南列表可以在这里找到.虽然它不包括 Visual Studio 2010明确地,指南也适用于当前版本.由方式,我们可以在这里使用 C# 作为项目类型,因为 C# based MVC项目实际上是 C# 项目(和 Web 应用程序项目).为了Visual Basic,您将使用{F184B08F-C81C-45F6-A57F-5ABD9991F28F}"而是.
$RootKey$ 是 VisualStudio 将配置存储在:HKEY_CURRENT_USERSoftwareMicrosoftVisualStudio10.0_Config(注:不要尝试手动编辑此键下的任何内容,因为它可以随时被 Visual Studio 覆盖).
其余的应该是不言自明的:此选项设置默认值将 .spark 文件的操作构建到内容",因此包含这些文件在发布过程中.
您现在需要做的就是将这段文本放入一个文件中扩展 pkgdef,把它放在下面的某个地方%PROGRAMFILES(x86)%Microsoft Visual Studio10.0Common7IDEExtensions(在 64 位系统上)或 %PROGRAMFILES(x86)%Microsoft Visual Studio10.0Common7IDEExtensions(在 32 位系统上)和 Visual Studio 将在下次启动时自动加载和应用设置.到撤消更改,只需删除文件.
Everytime I add an xsd file to my Visual Studio 2008 build project, its build action is defaulted to "none". I regularly forget to put this one to "content" which messes up the build...
Is there anyway to set the default build action of xsd files to "content"?
Finally found the answer in another stackoverflow question:
http://blog.andreloker.de/post/2010/07/02/Visual-Studio-default-build-action-for-non-default-file-types.aspx
From the article:
CHANGING THE DEFAULT BUILD ACTION FOR A FILE-TYPE 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:
1: [$RootKey$Projects{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}FileExtensions.spark] 2: "DefaultBuildAction"="Content" 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 in abstraction of the real registry key that Visual Studio stores the configuration under: HKEY_CURRENT_USERSoftwareMicrosoftVisualStudio10.0_Config (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 %PROGRAMFILES(x86)%Microsoft Visual Studio 10.0Common7IDEExtensions (on 64-bit systems) or %PROGRAMFILES(x86)%Microsoft Visual Studio 10.0Common7IDEExtensions (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.
这篇关于文件类型的默认构建操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!