在大多数情况下,您只需将Visual Studio为您设置的任何内容作为默认值……我指的是在解决方案资源管理器中选择的每个文件的BuildAction属性。有很多选择,很难知道每一个会做什么。
当前回答
Microsoft Connect的这一页(解释DesignData和DesignDataWithDesignTimeCreatableTypes)类型如何?引用:
下面描述了样本数据文件的两个构建操作。
样例数据.xaml文件必须分配以下构建操作之一:
DesignData:样例数据类型将被创建为伪类型。当样例数据类型不可创建或具有您希望为其定义样例数据值的只读属性时,请使用此构建操作。
DesignDataWithDesignTimeCreatableTypes:使用样例数据文件中定义的类型创建样例数据类型。当可以使用样例数据类型的默认空构造函数创建样例数据类型时,使用此构建操作。
不是很详尽,但至少给了一个提示。这个MSDN演练也提供了一些想法。我不知道这些构建操作是否也适用于非silverlight项目。
其他回答
从文档中可以看到:
The BuildAction property indicates what Visual Studio does with a file when a build is executed. BuildAction can have one of several values: None - The file is not included in the project output group and is not compiled in the build process. An example is a text file that contains documentation, such as a Readme file. Compile - The file is compiled into the build output. This setting is used for code files. Content - The file is not compiled, but is included in the Content output group. For example, this setting is the default value for an .htm or other kind of Web file. Embedded Resource - This file is embedded in the main project build output as a DLL or executable. It is typically used for resource files.
None: The file is not included in the project output group and is not compiled in the build process. An example is a text file that contains documentation, such as a Readme file. Compile: The file is compiled into the build output. This setting is used for code files. Content: Allows you to retrieve a file (in the same directory as the assembly) as a stream via Application.GetContentStream(URI). For this method to work, it needs a AssemblyAssociatedContentFile custom attribute which Visual Studio graciously adds when you mark a file as "Content" Embedded resource: Embeds the file in an exclusive assembly manifest resource. Resource (WPF only): Embeds the file in a shared (by all files in the assembly with similar setting) assembly manifest resource named AppName.g.resources. Page (WPF only): Used to compile a xaml file into baml. The baml is then embedded with the same technique as Resource (i.e. available as `AppName.g.resources) ApplicationDefinition (WPF only): Mark the XAML/class file that defines your application. You specify the code-behind with the x:Class="Namespace.ClassName" and set the startup form/page with StartupUri="Window1.xaml" SplashScreen (WPF only): An image that is marked as SplashScreen is shown automatically when an WPF application loads, and then fades DesignData: Compiles XAML viewmodels so that usercontrols can be previewed with sample data in Visual Studio (uses mock types) DesignDataWithDesignTimeCreatableTypes: Compiles XAML viewmodels so that usercontrols can be previewed with sample data in Visual Studio (uses actual types) EntityDeploy: (Entity Framework): used to deploy the Entity Framework artifacts CodeAnalysisDictionary: An XML file containing custom word dictionary for spelling rules
Page -- Takes the specified XAML file, and compiles into BAML, and embeds that output into the managed resource stream for your assembly (specifically AssemblyName.g.resources), Additionally, if you have the appropriate attributes on the root XAML element in the file, it will create a blah.g.cs file, which will contain a partial class of the "codebehind" for that page; this basically involves a call to the BAML goop to re-hydrate the file into memory, and to set any of the member variables of your class to the now-created items (e.g. if you put x:Name="foo" on an item, you'll be able to do this.foo.Background = Purple; or similar.
ApplicationDefinition——类似于Page,只不过它更进一步,为你的应用程序定义入口点,该入口点将实例化你的应用程序对象,在它上调用run,然后实例化由StartupUri属性设置的类型,并将给出你的主窗口。
同时,需要明确的是,这个问题在它的结果集中是无限的;任何人都可以通过构建MSBuild任务来定义额外的BuildActions。如果您查看%systemroot%\Microsoft.net\framework\v{version}\目录,并查看Microsoft.Common.targets文件,您应该能够破译更多(例如,在VS Pro和以上版本中,有一个“Shadow”操作,允许您生成私有访问器来帮助单元测试私有类。
Fakes: Microsoft Fakes(单元测试隔离)框架的一部分。在所有Visual Studio版本上不可用。Fakes用于支持项目中的单元测试,通过用stub或shims替换应用程序的其他部分来帮助您隔离正在测试的代码。更多信息请点击:https://msdn.microsoft.com/en-us/library/hh549175.aspx
在VS2008中,最有用的文档条目是:
构建WPF应用程序(WPF)
ms-help: / / MS.VSCC.v90 / MS.MSDNQTR.v90.en / wpf_conceptual / html / a58696fd bdad - 4 b55 - 9759 - 136 - dfdf8b91c.htm
ApplicationDefinition 标识包含应用程序定义的XAML标记文件(根元素为application的XAML标记文件)。当Install为true且OutputType为winexe时,ApplicationDefinition是必选项。一个WPF应用程序以及MSBuild项目只能有一个ApplicationDefinition。
页面 标识一个XAML标记文件,该文件的内容被转换为二进制格式并编译为程序集。页面项通常与代码隐藏类一起实现。
最常见的Page项是XAML文件,其顶级元素是以下其中之一:
Window (System.Windows..::.Window).
Page (System.Windows.Controls..::.Page).
PageFunction (System.Windows.Navigation..::.PageFunction<(Of <(T>)>)).
ResourceDictionary (System.Windows..::.ResourceDictionary).
FlowDocument (System.Windows.Documents..::.FlowDocument).
UserControl (System.Windows.Controls..::.UserControl).
资源 标识编译为应用程序程序集的资源文件。如前所述,UICulture处理资源项。
内容 标识随应用程序分发的内容文件。描述内容文件的元数据被编译到应用程序中(使用AssemblyAssociatedContentFileAttribute)。
推荐文章
- Visual Studio代码如何解决合并冲突与git?
- _references.js是用来做什么的?
- 如何为新的c#类/接口编辑Visual Studio模板?
- IIS Express Windows身份验证
- 配置系统初始化失败
- 在Visual Studio中是否有标准的快捷键来构建当前项目?
- 我如何让我的解决方案在Visual Studio回到在线的TFS?
- 如何在Visual Studio中生成getter和setter ?
- Visual Studio后构建事件-复制到相对目录位置
- 指定的参数超出有效值范围。参数名称:site
- 如何使用MS Visual Studio进行Android开发?
- 在安装了Resharper的Visual Studio中,键盘快捷键不活跃
- 在Visual Studio中如何在项目/解决方案之间共享代码?
- 用于自动添加“using”语句的Visual Studio键盘快捷方式
- Resharper Alt Enter不工作