問題描述
每次我將 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模板網!