Skip to content

Commit 05daccb

Browse files
Learn Build Service GitHub AppLearn Build Service GitHub App
authored andcommitted
Merging changes synced from https://github.com/MicrosoftDocs/visualstudio-docs-pr (branch live)
2 parents ae95b04 + a598f9c commit 05daccb

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

docs/msbuild/property-functions.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,26 @@ The following example shows how this function is used.
409409
</Project>
410410
```
411411

412+
From MSBuild version 17.10.0 this function accepts second, optional, argument requesting the hashing algorithm to be used:
413+
414+
```xml
415+
<Project>
416+
<PropertyGroup>
417+
<MyHash>$([MSBuild]::StableStringHash("test1", "Sha256"))</MyHash>
418+
</PropertyGroup>
419+
420+
<Target Name="WriteHash" AfterTargets="Build">
421+
<Message Text="Hash: $(MyHash)"/>
422+
</Target>
423+
</Project>
424+
```
425+
426+
The second argument is case insensitive and currently supports following values:
427+
* Legacy - keeps the same behavior as calling the function without the second argument. Returns signed 32bit integer with similar properties as `string.GetHashCode`.
428+
* Fnv1a32bit - Returns signed 32bit integer representing a [Fowler–Noll–Vo hash of version '1a'](https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function#FNV-1a_hash) hash of the given string.
429+
* Fnv1a64bit - Returns signed 64bit integer representing a [Fowler–Noll–Vo hash of version '1a'](https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function#FNV-1a_hash) hash of the given string.
430+
* Sha256 - Returns unprefixed hex string representing a SHA256 hash of the given string.
431+
412432
## MSBuild ValueOrDefault
413433

414434
The MSBuild `ValueOrDefault` property function returns the first argument, unless it's null or empty. If the first argument is null or empty, the function returns the second argument.

0 commit comments

Comments
 (0)