一般 MSBuild 專案項目Common MSBuild project items

在 MSBuild 中,項是對一個或多個檔的命名引用。In MSBuild, an item is a named reference to one or more files. 項目包含中繼資料,例如檔案名稱、路徑和版本號碼。Items contain metadata such as file names, paths, and version numbers. Visual Studio 中的所有專案類型都有多個共同專案。All project types in Visual Studio have several items in common. 這些專案在Microsoft.Build.CommonTypes.xsd檔中定義。These items are defined in the file Microsoft.Build.CommonTypes.xsd.

共同項目Common items

下列是所有共同專案項目的清單。The following is a list of all the common project items. 下列是所有共同專案項目的清單。The following is a list of all the common project items.

參考Reference

代表專案中的組件 (受管理) 參考。Represents an assembly (managed) reference in the project.

項目中繼資料名稱Item metadata name 描述Description
提示路徑HintPath 選擇性字串。Optional string. 組件的相對或絕對路徑。Relative or absolute path of the assembly.
名稱Name 選擇性字串。Optional string. 組件的顯示名稱,例如,"System.Windows.Forms"。The display name of the assembly, for example, "System.Windows.Forms."
融合名稱FusionName 選擇性字串。Optional string. 指定項目的簡單或強式融合名稱。Specifies the simple or strong fusion name for the item.

當這個屬性存在時,就可以節省時間,因為不需要開啟組件檔案就能取得融合名稱。When this attribute is present, it can save time because the assembly file does not have to be opened to obtain the fusion name.
特定版本SpecificVersion 選擇性布林值。Optional boolean. 指定是否應僅參考融合名稱中的版本。Specifies whether only the version in the fusion name should be referenced.
別名Aliases 選擇性字串。Optional string. 參考的任何別名。Any aliases for the reference.
PrivatePrivate 選擇性布林值。Optional boolean. 指定是否應將參考複製到輸出資料夾。Specifies whether the reference should be copied to the output folder. 此屬性與 Visual Studio IDE 中參考的 [複製到本機]**** 屬性相符。This attribute matches the Copy Local property of the reference that's in the Visual Studio IDE.

COM 參考COMReference

代表專案中的 COM (未受管理) 元件參考。Represents a COM (unmanaged) component reference in the project. 此項目僅適用於 .NET 專案。This item applies only to .NET projects.

項目中繼資料名稱Item metadata name 描述Description
名稱Name 選擇性字串。Optional string. 元件的顯示名稱。The display name of the component.
GuidGuid 必要字串。Required string. 元件的 GUID,格式為 {12345678-1234-1234-1234-1234567891234}。A GUID for the component, in the form {12345678-1234-1234-1234-1234567891234}.
VersionMajorVersionMajor 必要字串。Required string. 元件的版本號碼主要部分。The major part of the version number of the component. 例如,如果完整版本號碼為"5.46",則主要部分為 "5"。For example, "5" if the full version number is "5.46."
VersionMinorVersionMinor 必要字串。Required string. 元件版本號碼的次要部分。The minor part of the version number of the component. 例如,如果完整版本號碼為"5.46",則次要部分為 "46"。For example, "46" if the full version number is "5.46."
LCIDLCID 選擇性字串。Optional string. 元件的地區設定識別碼。The LocaleID for the component.
包裝函式工具WrapperTool 選擇性字串。Optional string. 用於元件的包裝函式工具名稱,例如 "tlbimp"。The name of the wrapper tool that is used on the component, for example, "tlbimp."
隔離Isolated 選擇性布林值。Optional boolean. 指定元件是否為免註冊元件。Specifies whether the component is a reg-free component.

COM 檔案參考COMFileReference

代表傳遞給 ResolveComReference 目標之 TypeLibFiles 參數的類型程式庫清單。Represents a list of type libraries that are passed to the TypeLibFiles parameter of the ResolveComReference target. 此項目僅適用於 .NET 專案。This item applies only to .NET projects.

項目中繼資料名稱Item metadata name 描述Description
包裝函式工具WrapperTool 選擇性字串。Optional string. 用於元件的包裝函式工具名稱,例如 "tlbimp"。The name of the wrapper tool that is used on the component, for example, "tlbimp."

原生參考NativeReference

代表原生的資訊清單檔案或是這類檔案的參考。Represents a native manifest file or a reference to such a file.

項目中繼資料名稱Item metadata name 描述Description
名稱Name 必要字串。Required string. 資訊清單檔案的基底名稱。The base name of the manifest file.
提示路徑HintPath 必要字串。Required string. 資訊清單檔案的相對路徑。The relative path of the manifest file.

專案參考ProjectReference

代表另一個專案的參考。Represents a reference to another project.

項目中繼資料名稱Item metadata name 描述Description
名稱Name 選擇性字串。Optional string. 參考的顯示名稱。The display name of the reference.
隨附此逐步解說的專案Project 選擇性字串。Optional string. 參考的 GUID,格式為 {12345678-1234-1234-1234-1234567891234}。A GUID for the reference, in the form {12345678-1234-1234-1234-1234567891234}.
PackagePackage 選擇性字串。Optional string. 所參考的專案檔路徑。The path of the project file that is being referenced.
ReferenceOutputAssemblyReferenceOutputAssembly 選擇性布林值。Optional boolean. 如果設定為 false,則不會將參考之專案的輸出,以參考的方式包含在此專案中,但仍然可確保其他專案會在此專案之前建置。If set to false, does not include the output of the referenced project as a Reference of this project, but still ensures that the other project builds before this one. 預設為 trueDefaults to true.

編譯Compile

代表編譯器的原始程式檔。Represents the source files for the compiler.

項目中繼資料名稱Item metadata name 描述Description
相依依據DependentUpon 選擇性字串。Optional string. 指定這個檔案必須倚賴才能正確編譯的檔案。Specifies the file this file depends on to compile correctly.
自動產生AutoGen 選擇性布林值。Optional boolean. 指示檔是否由 Visual Studio 整合式開發環境 (IDE) 生成。Indicates whether the file was generated for the project by the Visual Studio integrated development environment (IDE).
連結Link 選擇性字串。Optional string. 當檔案實際位於專案檔影響力之外時所顯示的標記路徑。The notational path to be displayed when the file is physically located outside the influence of the project file.
可見Visible 選擇性布林值。Optional boolean. 指示是否在視覺化工作室中的解決方案資源管理器中顯示該檔。Indicates whether to display the file in Solution Explorer in Visual Studio.
複製到輸出目錄CopyToOutputDirectory 選擇性字串。Optional string. 決定是否要將檔案複製到輸出目錄。Determines whether to copy the file to the output directory. 值為:Values are:

1. 從不1. Never
2. 始終2. Always
3. 保留最新3. PreserveNewest

內嵌資源EmbeddedResource

代表要內嵌於所產生組件中的資源。Represents resources to be embedded in the generated assembly.

項目中繼資料名稱Item metadata name 描述Description
相依依據DependentUpon 選擇性字串。Optional string. 指定這個檔案必須倚賴才能正確編譯的檔案Specifies the file this file depends on to compile correctly
GeneratorGenerator 必要字串。Required string. 在此項目上執行的任何檔案產生器名稱。The name of any file generator that is run on this item.
最後產生輸出LastGenOutput 必要字串。Required string. 在此項目執行的任何檔案產生器所建立的檔案名稱。The name of the file that was created by any file generator that ran on this item.
自訂工具命名空間CustomToolNamespace 必要字串。Required string. 在此項目上執行的任何檔案產生器應在其中建立程式碼的命名空間。The namespace in which any file generator that runs on this item should create code.
連結Link 選擇性字串。Optional string. 如果檔案實際位於專案影響力之外,便會顯示標記路徑。The notational path is displayed if the file is physically located outside the influence of the project.
可見Visible 選擇性布林值。Optional boolean. 指示是否在視覺化工作室中的解決方案資源管理器中顯示該檔。Indicates whether to display the file in Solution Explorer in Visual Studio.
複製到輸出目錄CopyToOutputDirectory 選擇性字串。Optional string. 決定是否要將檔案複製到輸出目錄。Determines whether to copy the file to the output directory. 值為:Values are:

1. 從不1. Never
2. 始終2. Always
3. 保留最新3. PreserveNewest
LogicalNameLogicalName 必要字串。Required string. 內嵌資源的邏輯名稱。The logical name of the embedded resource.

內容Content

代表不會編譯到專案中,但可能內嵌或一起發行的檔案。Represents files that are not compiled into the project, but may be embedded or published together with it.

項目中繼資料名稱Item metadata name 描述Description
相依依據DependentUpon 選擇性字串。Optional string. 指定這個檔案必須倚賴才能正確編譯的檔案。Specifies the file this file depends on to compile correctly.
GeneratorGenerator 必要字串。Required string. 在此項目上執行的任何檔案產生器名稱。The name of any file generator that runs on this item.
最後產生輸出LastGenOutput 必要字串。Required string. 在此項目執行的任何檔案產生器所建立的檔案名稱。The name of the file that was created by any file generator that was run on this item.
自訂工具命名空間CustomToolNamespace 必要字串。Required string. 在此項目上執行的任何檔案產生器應在其中建立程式碼的命名空間。The namespace in which any file generator that runs on this item should create code.
連結Link 選擇性字串。Optional string. 如果檔案實際位於專案影響力之外,便會顯示標記路徑。The notational path to be displayed if the file is physically located outside the influence of the project.
發行狀態PublishState 必要字串。Required string. 內容的發行狀態,可以是:The publish state of the content, either:

- 預設值- Default
- 包含- Included
- 排除- Excluded
- 資料檔- DataFile
- 必要條件- Prerequisite
為組件IsAssembly 選擇性布林值。Optional boolean. 指定檔案是否為組件。Specifies whether the file is an assembly.
可見Visible 選擇性布林值。Optional boolean. 指示是否在視覺化工作室中的解決方案資源管理器中顯示該檔。Indicates whether to display the file in Solution Explorer in Visual Studio.
複製到輸出目錄CopyToOutputDirectory 選擇性字串。Optional string. 決定是否要將檔案複製到輸出目錄。Determines whether to copy the file to the output directory. 值為:Values are:

1. 從不1. Never
2. 始終2. Always
3. 保留最新3. PreserveNewest

NoneNone

代表在建置流程中應該沒有任何角色的檔案。Represents files that should have no role in the build process.

項目中繼資料名稱Item metadata name 描述Description
相依依據DependentUpon 選擇性字串。Optional string. 指定這個檔案必須倚賴才能正確編譯的檔案。Specifies the file this file depends on to compile correctly.
GeneratorGenerator 必要字串。Required string. 在此項目上執行的任何檔案產生器名稱。The name of any file generator that is run on this item.
最後產生輸出LastGenOutput 必要字串。Required string. 在此項目執行的任何檔案產生器所建立的檔案名稱。The name of the file that was created by any file generator that ran on this item.
自訂工具命名空間CustomToolNamespace 必要字串。Required string. 在此項目上執行的任何檔案產生器應在其中建立程式碼的命名空間。The namespace in which any file generator that runs on this item should create code.
連結Link 選擇性字串。Optional string. 如果檔案實際位於專案影響力之外,便會顯示標記路徑。The notational path to be displayed if the file is physically located outside the influence of the project.
可見Visible 選擇性布林值。Optional boolean. 指示是否在視覺化工作室中的解決方案資源管理器中顯示該檔。Indicates whether to display the file in Solution Explorer in Visual Studio.
複製到輸出目錄CopyToOutputDirectory 選擇性字串。Optional string. 決定是否要將檔案複製到輸出目錄。Determines whether to copy the file to the output directory. 值為:Values are:

1. 從不1. Never
2. 始終2. Always
3. 保留最新3. PreserveNewest

組件中繼資料AssemblyMetadata

表示要生成的[AssemblyMetadata(key, value)]程式集屬性為 。Represents assembly attributes to be generated as [AssemblyMetadata(key, value)].

項目中繼資料名稱Item metadata name 描述Description
包含Include 成為AssemblyMetadataAttribute屬性建構函式中的第一個參數(鍵)。Becomes the first parameter (the key) in the AssemblyMetadataAttribute attribute constructor.
Value 必要字串。Required string. 成為AssemblyMetadataAttribute屬性建構函式中的第二個參數(值)。Becomes the second parameter (the value) in the AssemblyMetadataAttribute attribute constructor.

注意

這僅適用于僅使用 .NET 核心 SDK 的專案。This applies to projects using the .NET Core SDK only.

基本應用程式資訊清單BaseApplicationManifest

表示生成的基本應用程式清單,並包含 ClickOnce 部署安全資訊。Represents the base application manifest for the build, and contains ClickOnce deployment security information.

程式碼分析匯入CodeAnalysisImport

代表要匯入的 FxCop 專案。Represents the FxCop project to import.

匯入Import

表示名稱空間應由可視基本編譯器導入的程式集。Represents assemblies whose namespaces should be imported by the Visual Basic compiler.

另請參閱See also