在大多数情况下,您只需将Visual Studio为您设置的任何内容作为默认值……我指的是在解决方案资源管理器中选择的每个文件的BuildAction属性。有很多选择,很难知道每一个会做什么。


当前回答

在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)。

其他回答

从文档中可以看到:

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.

Fakes: Microsoft Fakes(单元测试隔离)框架的一部分。在所有Visual Studio版本上不可用。Fakes用于支持项目中的单元测试,通过用stub或shims替换应用程序的其他部分来帮助您隔离正在测试的代码。更多信息请点击:https://msdn.microsoft.com/en-us/library/hh549175.aspx

VS2010有一个属性用于“构建动作”,还有一个属性用于“复制到输出目录”。因此,如果复制属性设置为“更新时复制”或“始终复制”,'None'的操作仍然会复制到构建目录。

因此,“内容”的构建动作应该保留,以指示您将通过“应用程序”访问的内容。GetContentStream”

对于一些外部链接的.config include,我使用了“None”的“构建动作”设置和“如果更新则复制到输出目录”的“复制到输出目录”设置。

G.

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”操作,允许您生成私有访问器来帮助单元测试私有类。