Skip to content

Fix git push error for protected CLA branch #4807

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

Merged
merged 4 commits into from
Feb 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions docs/msbuild/verifyfilehash-task.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ms.workload:
---
# VerifyFileHash task

Verifies that a file matches the expected file hash.
Verifies that a file matches the expected file hash. If the hash doesn't match, the task fails.

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.

Expand Down Expand Up @@ -55,7 +55,31 @@ The following example uses the `VerifyFileHash` task to verify its own checksum.
</Project>
```

On MSBuild 16.5 and later, if you don't want the build to fail when the hash doesn't match, such as if you are using the hash comparison as a condition for control flow, you can downgrade the warning to a message using the following code:

```xml
<PropertyGroup>
<MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);MSB3952</MSBuildWarningsAsMessages>
</PropertyGroup>

<Target Name="DemoVerifyCheck">
<VerifyFileHash File="$(MSBuildThisFileFullPath)"
Hash="1"
ContinueOnError="WarnAndContinue" />

<PropertyGroup>
<HashMatched>$(MSBuildLastTaskResult)</HashMatched>
</PropertyGroup>

<Message Condition=" '$(HashMatched)' != 'true'"
Text="The hash didn't match" />

<Message Condition=" '$(HashMatched)' == 'true'"
Text="The hash did match" />
</Target>
```

## See also

- [Tasks](../msbuild/msbuild-tasks.md)
- [Task reference](../msbuild/msbuild-task-reference.md)
- [Task reference](../msbuild/msbuild-task-reference.md)