-
Notifications
You must be signed in to change notification settings - Fork 1.7k
MSBuild: Document VerifyFileHash task #2279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| --- | ||
| title: "GetFileHash Task | Microsoft Docs" | ||
| ms.date: "01/28/2019" | ||
| ms.topic: "reference" | ||
| f1_keywords: | ||
| - "http://schemas.microsoft.com/developer/msbuild/2003#GetFileHash" | ||
| dev_langs: | ||
| - "VB" | ||
| - "CSharp" | ||
| - "C++" | ||
| - "jsharp" | ||
| helpviewer_keywords: | ||
| - "GetFileHash task [MSBuild]" | ||
| - "MSBuild, GetFileHash task" | ||
| ms.assetid: ??? | ||
| author: mikejo5000 | ||
| ms.author: mikejo | ||
| manager: jillfra | ||
| ms.workload: | ||
| - "multiple" | ||
| --- | ||
| # GetFileHash task | ||
|
|
||
| Computes checksums of the contents of a file or set of files. | ||
|
|
||
| This task was added in 15.8, but requires a [workaround](https://github.com/Microsoft/msbuild/pull/3999#issuecomment-458193272) to use for MSBuild versions below 16.0. | ||
|
|
||
| ## Task parameters | ||
|
|
||
| The following table describes the parameters of the `GetFileHash` task. | ||
|
|
||
| |Parameter|Description| | ||
| |---------------|-----------------| | ||
| |`Files`|Required <xref:Microsoft.Build.Framework.ITaskItem>`[]` parameter.<br /><br />The files to be hashed.| | ||
| |`Items`|<xref:Microsoft.Build.Framework.ITaskItem>`[]` output parameter.<br /><br />The `Files` input with additional metadata set to the file hash.| | ||
| |`Hash`|`String` output parameter.<br /><br />The hash of the file. This is only set if there was exactly one item passed in.| | ||
| |`Algorithm`|Optional `String` parameter.<br /><br />The algorithm. Allowed values: `SHA256`, `SHA384`, `SHA512`. Default = `SHA256`.| | ||
| |`MetadataName`|Optional `String` parameter.<br /><br />The metadata name where the hash is stored in each item. Defaults to `FileHash`.| | ||
| |`HashEncoding`|Optional `String` parameter.<br /><br />The encoding to use for generated hashes. Defaults to `hex`. Allowed values = `hex`, `base64`.| | ||
|
|
||
| ## Example | ||
|
|
||
| The following example uses the `GetFileHash` task to determine and print the checksum of the `FilesToHash` items. | ||
|
|
||
| ```xml | ||
| <Project> | ||
| <ItemGroup> | ||
| <FilesToHash Include="$(MSBuildThisFileDirectory)\*" /> | ||
| </ItemGroup> | ||
| <Target Name="GetHash"> | ||
| <GetFileHash Files="@(FilesToHash)"> | ||
| <Output | ||
| TaskParameter="Items" | ||
| ItemName="FilesWithHashes" /> | ||
| </GetFileHash> | ||
|
|
||
| <Message Importance="High" | ||
| Text="@(FilesWithHashes->'%(Identity): %(FileHash)')" /> | ||
| </Target> | ||
| </Project> | ||
| ``` | ||
|
|
||
| ## See also | ||
|
|
||
| [Tasks](../msbuild/msbuild-tasks.md) | ||
|
|
||
| [Task reference](../msbuild/msbuild-task-reference.md) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| --- | ||
| title: "VerifyFileHash Task | Microsoft Docs" | ||
| ms.date: "01/28/2019" | ||
| ms.topic: "reference" | ||
| f1_keywords: | ||
| - "http://schemas.microsoft.com/developer/msbuild/2003#VerifyFileHash" | ||
| dev_langs: | ||
| - "VB" | ||
| - "CSharp" | ||
| - "C++" | ||
| - "jsharp" | ||
| helpviewer_keywords: | ||
| - "VerifyFileHash task [MSBuild]" | ||
| - "MSBuild, VerifyFileHash task" | ||
| ms.assetid: ??? | ||
| author: mikejo5000 | ||
| ms.author: mikejo | ||
| manager: jillfra | ||
| ms.workload: | ||
| - "multiple" | ||
| --- | ||
| # VerifyFileHash task | ||
|
|
||
| Verifies that a file matches the expected file hash. | ||
|
|
||
| This task was added in 15.8, but requires a [workaround](https://github.com/Microsoft/msbuild/pull/3999#issuecomment-458193272) to use for MSBuild versions below 16.0. | ||
|
|
||
| ## Task parameters | ||
|
|
||
| The following table describes the parameters of the `VerifyFileHash` task. | ||
|
|
||
| |Parameter|Description| | ||
| |---------------|-----------------| | ||
| |`File`|Required <xref:Microsoft.Build.Framework.ITaskItem> parameter.<br /><br />The files to be hashed and validated.| | ||
| |`Hash`|Required `String` parameter.<br /><br />The expected hash of the file.| | ||
| |`Items`|<xref:Microsoft.Build.Framework.ITaskItem>`[]` output parameter.<br /><br />The `Files` input with additional metadata set to the file hash.| | ||
| |`Algorithm`|Optional `String` parameter.<br /><br />The algorithm. Allowed values: `SHA256`, `SHA384`, `SHA512`. Default = `SHA256`.| | ||
| |`HashEncoding`|Optional `String` parameter.<br /><br />The encoding to use for generated hashes. Defaults to `hex`. Allowed values = `hex`, `base64`.| | ||
|
|
||
| ## Example | ||
|
|
||
| The following example uses the `VerifyFileHash` task to verify its own checksum. | ||
|
|
||
| ```xml | ||
| <Project> | ||
| <Target Name="VerifyHash"> | ||
| <GetFileHash Files="$(MSBuildProjectFullPath)"> | ||
| <Output | ||
| TaskParameter="Items" | ||
| ItemName="FilesWithHashes" /> | ||
| </GetFileHash> | ||
|
|
||
| <Message Importance="High" | ||
| Text="@(FilesWithHashes->'%(Identity): %(FileHash)')" /> | ||
|
|
||
| <VerifyFileHash File="$(MSBuildThisFileFullPath)" | ||
| Hash="$(ExpectedHash)" /> | ||
| </Target> | ||
| </Project> | ||
| ``` | ||
|
|
||
| ## See also | ||
|
|
||
| [Tasks](../msbuild/msbuild-tasks.md) | ||
|
|
||
| [Task reference](../msbuild/msbuild-task-reference.md) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mikejo5000 should I just create a new GUID for these, or is there something else I could do to help? In general I was guessing on a lot of this metadata.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rainersigwald ms.assetid is used only for topics migrated from MSDN, so please remove that. Everything else looks good except f1_keywords. This metadata item is for F1 links from the IDE (if an F1 link exists) formatted like this example: vc.task.xdcmake
If there's no plan to link to the topic from the IDE, just remove f1_keywords.
Thanks!