MSBuild 工作參考MSBuild task reference

提供在建置流程期間執行之程式碼的工作。Tasks provide the code that runs during the build process. 下列清單的工作包含於 MSBuildMSBuild 中。The tasks in the following list are included with MSBuildMSBuild. 若已安裝 Visual C++Visual C++,將提供可用來建置 Visual C++Visual C++ 專案的其他工作。When Visual C++Visual C++ is installed, additional tasks are available that are used to build Visual C++Visual C++ projects. 如需詳細資訊,請參閱 Visual C++ 工作For more information, see Visual C++ tasks.

除了本節中主題所列的參數之外,每個工作也會有下列參數:In addition to the parameters listed in the topics in this section, each task also has the following parameters:

參數Parameter 說明Description
Condition 選擇性的 String 參數。Optional String parameter.

Boolean 運算式,MSBuildMSBuild 引擎會使用此運算式來決定是否要執行此工作。A Boolean expression that the MSBuildMSBuild engine uses to determine whether this task will be executed. 如需 MSBuildMSBuild 所支援條件的相關資訊,請參閱條件For information about the conditions that are supported by MSBuildMSBuild, see Conditions.
ContinueOnError 選擇性參數。Optional parameter. 可包含一或多個下列值:Can contain one of the following values:

- WarnAndContinuetrue- WarnAndContinue or true. 當工作失敗時,Target 項目中的後續工作與組建都會繼續執行,並將來自工作的所有錯誤視為警告。When a task fails, subsequent tasks in the Target element and the build continue to execute, and all errors from the task are treated as warnings.
- ErrorAndContinue- ErrorAndContinue. 當工作失敗時,Target 項目中的後續工作與組建都會繼續執行,並將來自工作的所有錯誤視為錯誤。When a task fails, subsequent tasks in the Target element and the build continue to execute, and all errors from the task are treated as errors.
- ErrorAndStopfalse (預設值)。- ErrorAndStop or false (default). 當工作失敗時,就不會執行 Target 項目中的其餘工作和組建,並將整個 Target 項目與組建視為失敗。When a task fails, the remaining tasks in the Target element and the build aren't executed, and the entire Target element and the build is considered to have failed.

只有 4.5 版之前的 .NET Framework 版本支援 truefalse 值。Versions of the .NET Framework before 4.5 supported only the true and false values.

如需詳細資訊,請參閱如何:忽略工作中的錯誤For more information, see How to: Ignore errors in tasks.

本節內容In this section

將數個參數新增至從 Task 類別衍生的工作。Adds several parameters to the tasks that derive from the Task class.

將數個參數新增至從 TaskExtension 類別衍生的工作。Adds several parameters to the tasks that derive from the TaskExtension class.

將數個參數新增至從 ToolTaskExtension 類別衍生的工作。Adds several parameters to the tasks that derive from the ToolTaskExtension class.

從一或多個模組或資源檔的檔案中,建立包含資訊清單的組件。Creates an assembly with a manifest from one or more files that are either modules or resource files.

包裝 aspnet_compiler.exe,此為預先編譯 ASP.NET 應用程式的公用程式。Wraps aspnet_compiler.exe, a utility to precompile ASP.NET applications.

將文化特性識別項指派給項目。Assigns culture identifiers to items.

接受組態字串清單,並將它們指派給指定的專案。Accepts a list of configuration strings and assigns them to specified projects.

接受檔案清單,並加入 <TargetPath> 屬性 (如果尚未指定)。Accepts a list of files and adds <TargetPath> attributes if they are not already specified.

叫用專案檔中的目標。Invokes a target in the project file.

將指定的路徑結合成單一路徑。Combines the specified paths into a single path.

將相對路徑或參考轉換為絕對路徑。Converts a relative path or reference into an absolute path.

將檔案複製到新位置。Copies files to a new location.

從指定的 .resx 檔案名稱或其他資源,建立 Visual C#Visual C# 樣式的資訊清單名稱。Creates a Visual C#Visual C#-style manifest name from a given .resx file name or other resource.

從輸入項目填入項目集合,以允許將項目從某一個清單複製到另一個。Populates item collections from the input items, allowing items to be copied from one list to another.

從輸入值填入屬性,以允許將值從某一個屬性或字串複製到另一個。Populates properties from the input values, allowing values to be copied from one property or string to another.

從指定的 .resx 檔案名稱或其他資源,建立 Visual BasicVisual Basic 樣式的資訊清單名稱。Creates a Visual BasicVisual Basic-style manifest name from a given .resx file name or other resource.

叫用 Visual C# 編譯器來產生可執行檔、動態連結程式庫或程式碼模組。Invokes the Visual C# compiler to produce executables, dynamic-link libraries, or code modules.

刪除指定的檔案。Deletes the specified files.

將檔案下載至指定的位置。Downloads a file to the specified location.

停止組建,並根據評估的條件陳述式來記錄錯誤。Stops a build and logs an error based on an evaluated conditional statement.

使用指定的引數來執行指定的程式或命令。Runs the specified program or command with the specified arguments.

在提供的清單中尋找 app.config 檔案 (若有的話)。Finds the app.config file, if any, in the provided lists.

在指定的清單中尋找具有相符項目規格的項目。Finds an item in a specified list that has the matching itemspec.

判斷指定項目集合中的哪些項目存在於指定的資料夾及其所有子資料夾中。Determines which items in the specified item collection exist in the specified folder and all of its subfolders.

將 URL 轉換為正確的 URL 格式。Converts a URL to a correct URL format.

將修訂編號附加至版本號碼。Appends the revision number to the version number.

產生 ClickOnceClickOnce 應用程式資訊清單或原生資訊清單。Generates a ClickOnceClickOnce application manifest or a native manifest.

提供自動化方式來偵測、下載及安裝應用程式及其必要條件。Provides an automated way to detect, download, and install an application and its prerequisites.

產生 ClickOnceClickOnce 部署資訊清單。Generates a ClickOnceClickOnce deployment manifest.

.txt.resx 檔案轉換為通用語言執行階段二進位 .resources 檔案。Converts .txt and .resx files to common language runtime binary .resources files.

從基底資訊清單,以及從 TargetZoneExcludedPermissions 參數產生應用程式信任。Generates the application trust from the base manifest, and from the TargetZone and ExcludedPermissions parameters.

從指定的檔案擷取組件識別,並輸出識別資訊。Retrieves the assembly identities from the specified files and outputs the identity information.

計算檔案或一組檔案內容的總和檢查碼。Computes checksums of the contents of a file or set of files.

擷取 .NET Framework 組件的路徑。Retrieves the path to the .NET Framework assemblies.

擷取 Windows Software Development Kit (SDK)Windows Software Development Kit (SDK) 的路徑。Retrieves the path to the Windows Software Development Kit (SDK)Windows Software Development Kit (SDK).

傳回各種架構的參考組件路徑。Returns the reference assembly paths of the various frameworks.

.licx 檔案產生 .license 檔案。Generates a .license file from a .licx file.

建立目錄,以及任何父目錄 (如有必要)。Creates directories and, if necessary, any parent directories.

在建置期間記錄訊息。Logs a message during a build.

將檔案移到新位置。Moves files to a new location.

從另一個 MSBuildMSBuild 專案建置MSBuildMSBuild 專案。Builds MSBuildMSBuild projects from another MSBuildMSBuild project.

從文字檔讀取項目清單。Reads a list of items from a text file.

讀取指定組件內的中繼資料,並將必要的項目加入至登錄。Reads the metadata within the specified assembly and adds the necessary entries to the registry.

移除指定的目錄及其所有檔案和子目錄。Removes the specified directories and all of its files and subdirectories.

從指定的項目集合中移除重複項目。Removes duplicate items from the specified item collection.

判斷應用程式是否需要 .NET Framework 3.5 SP1。Determines whether the application requires the .NET Framework 3.5 SP1.

  • ResGen 工作ResGen Task

已過時。Obsolete. 使用 GenerateResource 工作,將 .txt.resx 檔案轉換為通用語言執行階段二進位 .resources 檔案,反之亦然。Use the GenerateResource task task to convert .txt and .resx files to and from common language runtime binary .resources files.

判斷相依於指定組件的所有組件。Determines all assemblies that depend on the specified assemblies.

取得一或多個類型程式庫名稱或 .tlb 檔案的清單,並將那些類型程式庫解析至磁碟上的位置。Takes a list of one or more type library names or .tlb files and resolves those type libraries to locations on disk.

決定強式名稱金鑰來源Determines the strong name key source

將建置流程中的下列項目解析為檔案,以產生資訊清單:建置的項目、相依性、附屬項目、內容、偵錯符號和文件。Resolves the following items in the build process to files for manifest generation: built items, dependencies, satellites, content, debug symbols, and documentation.

解析原生參考。Resolves native references.

決定非 MSBuild 專案參考的輸出檔。Determines the output files for non-MSBuild project references.

針對指定組件中的型別建立 XML 序列化組件。Creates an XML serialization assembly for types in the specified assembly.

使用指定的憑證簽署指定的檔案。Signs the specified file using the specified certificate.

設定檔案的存取和修改時間。Sets the access and modification times of files.

針對 COM Interop 用途將指定的組件取消註冊。Unregisters the specified assemblies for COM interop purposes.

.zip 封存解壓縮至指定的位置。Unzips a .zip archive to the specified location.

更新資訊清單中選取的屬性,並重新簽署。Updates selected properties in a manifest and resigns.

叫用 Visual Basic 編譯器來產生可執行檔、動態連結程式庫或程式碼模組。Invokes the Visual Basic compiler to produce executables, dynamic-link libraries, or code modules..

驗證檔案是否符合預期的檔案雜湊。Verifies that a file matches the expected file hash.

在建置期間,根據評估的條件陳述式來記錄警告。Logs a warning during a build based on an evaluated conditional statement.

使用指定產生的程式碼片段來產生暫存程式碼檔。Generates a temporary code file by using the specified generated code fragment. 不會刪除該檔案。Does not delete the file.

將指定的項目寫入指定的文字檔。Writes the specified items to the specified text file.

將 XPath 查詢所指定的值從 XML 檔案傳回。Returns values as specified by XPath query from an XML file.

將 XPath 查詢所指定的值設定至 XML 檔案。Sets values as specified by an XPath query into an XML file.

使用「可延伸樣式表語言轉換」 (XSLT) 或編譯的 XSLT 轉換 XML 輸入,並輸出到輸出裝置或檔案。Transforms an XML input by using an Extensible Stylesheet Language Transformation (XSLT) or compiled XSLT and outputs to an output device or a file.

從目錄的內容建立 .zip 封存。Creates a .zip archive from the contents of a directory.

另請參閱See also