You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`double Add(double a, double b)`|Add two doubles.|
@@ -229,16 +230,16 @@ Here is a list of MSBuild property functions:
229
230
|`bool IsOsBsdLike()`|True if the current OS is a BSD-style Unix system.|
230
231
|`bool IsOSUnixLike()`|True if current OS is a Unix system.|
231
232
|`bool IsTargetFrameworkCompatible(string targetFrameworkTarget, string targetFrameworkCandidate)`|Return 'True' if the candidate target framework (second argument) is compatible with the target framework indicated by the first argument, and false otherwise. See [MSBuild TargetFramework and TargetPlatform functions](#msbuild-targetframework-and-targetplatform-functions).|
232
-
|`int LeftShift(int operand, int count)`| Shift left by `count` bits.|
233
+
|`int LeftShift(int operand, int count)`| Shift left by `count` bits. MSBuild 17.7 and later. |
233
234
|`string MakeRelative(string basePath, string path)`|Makes `path` relative to `basePath`. `basePath` must be an absolute directory. If `path` cannot be made relative, it is returned verbatim. Similar to `Uri.MakeRelativeUri`. See [MSBuild MakeRelative](#msbuild-makerelative).|
234
235
|`double Modulo(double a, double b)`|Modulo two doubles.|
235
236
|`long Modulo(long a, long b)`|Modulo two longs.|
236
237
|`double Multiply(double a, double b)`|Multiply two doubles.|
237
238
|`long Multiply(long a, long b)`|Multiply two longs.|
238
239
|`string NormalizeDirectory(params string[] path)`|Gets the canonicalized full path of the provided directory and ensures it contains the correct directory separator characters for the current operating system while ensuring it has a trailing slash.|
239
240
|`string NormalizePath(params string[] path)`|Gets the canonicalized full path of the provided path and ensures it contains the correct directory separator characters for the current operating system.|
240
-
|`int RightShift(int operand, int count)`| Shift right by `count` bits, as a signed integer. |
241
-
|`int RightShiftUnsigned(int operand, int count)`| Shift right by `count` bits, treating the operand as an unsigned integer.|
241
+
|`int RightShift(int operand, int count)`| Shift right by `count` bits, as a signed integer. MSBuild 17.7 and later. |
242
+
|`int RightShiftUnsigned(int operand, int count)`| Shift right by `count` bits, treating the operand as an unsigned integer. MSBuild 17.7 and later. |
242
243
|`object StableStringHash(string toHash, StringHashingAlgorithm algo)`| Accepts a string argument, and returns a hash code that is guaranteed to be stable. See [MSBuild StableStringHash](#msbuild-stablestringhash).|
243
244
|`string SubstringByAsciiChars(string input, int start, int length)`|Returns a substring of `input`, starting at the specified `start` position and with the specified `length`, treating the string as ASCII-encoded.|
244
245
|`double Subtract(double a, double b)`|Subtract two doubles.|
@@ -251,6 +252,64 @@ Here is a list of MSBuild property functions:
251
252
|`bool VersionLessThan(string a, string b)`|Return `true` if version `a` is less than `b` according to the below rules. See [MSBuild Version comparison functions](#msbuild-version-comparison-functions). |
252
253
|`bool VersionLessThanOrEquals(string a, string b)`|Return `true` if version `a` is less than or equal to `b` according to the below rules. See [MSBuild Version comparison functions](#msbuild-version-comparison-functions). |
253
254
|`bool VersionNotEquals(string a, string b)`|Return `false` if versions `a` and `b` are equivalent according to the below rules. See [MSBuild Version comparison functions](#msbuild-version-comparison-functions). |
255
+
:::moniker-end
256
+
257
+
:::moniker range="<=vs-2019"
258
+
|Function signature|Description|
259
+
|------------------------|-----------------|
260
+
|`double Add(double a, double b)`|Add two doubles.|
261
+
|`long Add(long a, long b)`|Add two longs.|
262
+
|`int BitwiseOr(int first, int second)`|Perform a bitwise `OR` on the first and second (first | second).|
263
+
|`int BitwiseAnd(int first, int second)`|Perform a bitwise `AND` on the first and second (first & second).|
264
+
|`int BitwiseXor(int first, int second)`|Perform a bitwise `XOR` on the first and second (first ^ second).|
265
+
|`int BitwiseNot(int first)`|Perform a bitwise `NOT` (~first).|
266
+
|`string CheckFeatureAvailability(string featureName)`| Returns the feature name as a string if and only if the specified feature is supported in this version of MSBuild. |
267
+
|`string ConvertToBase64(string toEncode)`|Returns the string after converting all bytes to base 64 (alphanumeric characters plus `+` and `/`), ending in one or two `=`.|
268
+
|`string ConvertFromBase64(string toDecode)`|Returns the string after converting from base 64 (alphanumeric characters plus `+` and `/`), ending in one or two `=`.|
269
+
|`double Divide(double a, double b)`|Divide two doubles.|
270
+
|`long Divide(long a, long b)`|Divide two longs.|
271
+
|`bool DoesTaskHostExist(string runtime, string architecture)`|Returns whether a task host is currently installed for the specified runtime and architecture values. See [MSBuild DoesTaskHostExist](#msbuild-doestaskhostexist). |
272
+
|`string Escape(string unescaped)`|Escape the string according to MSBuild escaping rules.|
273
+
|`string EnsureTrailingSlash(string path)`|If the given path doesn't have a trailing slash then add one. If the path is an empty string, does not modify it. See [MSBuild EnsureTrailingSlash](#msbuild-ensuretrailingslash).|
274
+
|`string GetCurrentToolsDirectory()`| Get the current MSBuild tools directory. |
275
+
|`string GetMSBuildExtensionsPath()`| Gets the MSBuild extensions path. When running *MSBuild.exe*, this is usually the MSBuild executable folder. When running in Visual Studio, this is the MSBuild subfolder under the Visual Studio installation folder. |
276
+
|`string GetMSBuildSDKsPath()`| Gets the directory where SDKs are expected, for the current MSBuild instance.|
277
+
|`string GetProgramFiles32()`| Gets the filesystem root folder where 32-bit software packages are typically installed. For example, `C:\Program Files (x86)`. |
278
+
|`string GetTargetFrameworkIdentifier(string targetFramework)`|Parse the TargetFrameworkIdentifier from the TargetFramework. See [MSBuild TargetFramework and TargetPlatform functions](#msbuild-targetframework-and-targetplatform-functions).|
279
+
|`string GetTargetFrameworkVersion(string targetFramework, int versionPartCount)`|Parse the TargetFrameworkVersion from the TargetFramework. See [MSBuild TargetFramework and TargetPlatform functions](#msbuild-targetframework-and-targetplatform-functions).|
280
+
|`string GetTargetPlatformIdentifier(string targetFramework)`|Parse the TargetPlatformIdentifier from the TargetFramework. See [MSBuild TargetFramework and TargetPlatform functions](#msbuild-targetframework-and-targetplatform-functions).|
281
+
|`string GetTargetPlatformVersion(string targetFramework, int versionPartCount)`|Parse the TargetPlatformVersion from the TargetFramework. See [MSBuild TargetFramework and TargetPlatform functions](#msbuild-targetframework-and-targetplatform-functions).|
282
+
|`string GetToolsDirectory32()`| Gets the directory where 32-bit versions of the MSBuild tools are located. |
283
+
|`string GetToolsDirectory64()`| Gets the directory where 64-bit versions of the MSBuild tools are located. |
284
+
|`string GetDirectoryNameOfFileAbove(string startingDirectory, string fileName)`|Locate and return the directory of a file in either the directory specified or a location in the directory structure above that directory. See [MSBuild GetDirectoryNameOfFileAbove](#msbuild-getdirectorynameoffileabove).|
285
+
|`string GetPathOfFileAbove(string file, string startingDirectory)`|Searches for and returns the full path to a file in the directory structure at and above the current build file's location, or based on `startingDirectory`, if specified. See [MSBuild GetPathOfFileAbove](#msbuild-getpathoffileabove). |
286
+
|`object GetRegistryValue(string keyName, string valueName, object defaultValue)`|Get the value of the registry key and value. See [MSBuild GetRegistryValue](#msbuild-getregistryvalue). |
287
+
|`object GetRegistryValueFromView(string keyName, string valueName, object defaultValue, params object[] views)`|Gets system registry data given the registry key, value, and one or more ordered registry views. See [MSBuild GetRegistryValueFromView](#msbuild-getregistryvaluefromview).|
288
+
|`string GetVsInstallRoot()`|Gets the full path to the root of the Visual Studio installation folder associated with the current instance of MSBuild.|
289
+
|`bool IsOsPlatform(string platformString)`|Specify whether the current OS platform is `platformString`. `platformString` must be a member of <xref:System.Runtime.InteropServices.OSPlatform>.|
290
+
|`bool IsOsBsdLike()`|True if the current OS is a BSD-style Unix system.|
291
+
|`bool IsOSUnixLike()`|True if current OS is a Unix system.|
292
+
|`bool IsTargetFrameworkCompatible(string targetFrameworkTarget, string targetFrameworkCandidate)`|Return 'True' if the candidate target framework (second argument) is compatible with the target framework indicated by the first argument, and false otherwise. See [MSBuild TargetFramework and TargetPlatform functions](#msbuild-targetframework-and-targetplatform-functions).|
293
+
|`string MakeRelative(string basePath, string path)`|Makes `path` relative to `basePath`. `basePath` must be an absolute directory. If `path` cannot be made relative, it is returned verbatim. Similar to `Uri.MakeRelativeUri`. See [MSBuild MakeRelative](#msbuild-makerelative).|
294
+
|`double Modulo(double a, double b)`|Modulo two doubles.|
295
+
|`long Modulo(long a, long b)`|Modulo two longs.|
296
+
|`double Multiply(double a, double b)`|Multiply two doubles.|
297
+
|`long Multiply(long a, long b)`|Multiply two longs.|
298
+
|`string NormalizeDirectory(params string[] path)`|Gets the canonicalized full path of the provided directory and ensures it contains the correct directory separator characters for the current operating system while ensuring it has a trailing slash.|
299
+
|`string NormalizePath(params string[] path)`|Gets the canonicalized full path of the provided path and ensures it contains the correct directory separator characters for the current operating system.|
300
+
|`object StableStringHash(string toHash, StringHashingAlgorithm algo)`| Accepts a string argument, and returns a hash code that is guaranteed to be stable. See [MSBuild StableStringHash](#msbuild-stablestringhash).|
301
+
|`string SubstringByAsciiChars(string input, int start, int length)`|Returns a substring of `input`, starting at the specified `start` position and with the specified `length`, treating the string as ASCII-encoded.|
302
+
|`double Subtract(double a, double b)`|Subtract two doubles.|
303
+
|`long Subtract(long a, long b)`|Subtract two longs.|
304
+
|`string Unescape(string escaped)`|Unescape the string according to MSBuild escaping rules.|
305
+
|`string ValueOrDefault(string conditionValue, string defaultValue)`|Returns the string in parameter `defaultValue` only if parameter `conditionValue` is empty, else, return the value `conditionValue`. See [MSBuild ValueOrDefault](#msbuild-valueordefault).|
306
+
|`bool VersionEquals(string a, string b)`|Return `true` if versions `a` and `b` are equivalent according to the below rules. See [MSBuild Version comparison functions](#msbuild-version-comparison-functions). |
307
+
|`bool VersionGreaterThan(string a, string b)`|Return `true` if version `a` is greater than `b` according to the below rules. See [MSBuild Version comparison functions](#msbuild-version-comparison-functions). |
308
+
|`bool VersionGreaterThanOrEquals(string a, string b)`|Return `true` if version `a` is greater than or equal to `b` according to the below rules. See [MSBuild Version comparison functions](#msbuild-version-comparison-functions). |
309
+
|`bool VersionLessThan(string a, string b)`|Return `true` if version `a` is less than `b` according to the below rules. See [MSBuild Version comparison functions](#msbuild-version-comparison-functions). |
310
+
|`bool VersionLessThanOrEquals(string a, string b)`|Return `true` if version `a` is less than or equal to `b` according to the below rules. See [MSBuild Version comparison functions](#msbuild-version-comparison-functions). |
311
+
|`bool VersionNotEquals(string a, string b)`|Return `false` if versions `a` and `b` are equivalent according to the below rules. See [MSBuild Version comparison functions](#msbuild-version-comparison-functions). |
312
+
:::moniker-end
254
313
255
314
## Nested property functions
256
315
@@ -499,6 +558,8 @@ Output:
499
558
500
559
MSBuild 16.7 and higher define several functions for handling [TargetFramework and TargetPlatform properties](msbuild-target-framework-and-target-platform.md).
501
560
561
+
:::moniker range=">=vs-2022"
562
+
502
563
|Function signature|Description|
503
564
|------------------------|-----------------|
504
565
|`FilterTargetFrameworks(string incoming, string filter)`|Return the list of the target frameworks that match the specified filter. An target framework from `incoming` is kept if it matches any of the desired target frameworks on `filter`.|
@@ -507,6 +568,18 @@ MSBuild 16.7 and higher define several functions for handling [TargetFramework a
507
568
|`GetTargetPlatformIdentifier(string targetFramework)`|Parse the TargetPlatformIdentifier from the TargetFramework.|
508
569
|`GetTargetPlatformVersion(string targetFramework, int versionPartCount)`|Parse the TargetPlatformVersion from the TargetFramework.|
509
570
|`IsTargetFrameworkCompatible(string targetFrameworkTarget, string targetFrameworkCandidate)`|Return 'True' if the candidate target framework (second argument) is compatible with the target framework indicated by the first argument, and false otherwise.|
571
+
:::moniker-end
572
+
573
+
:::moniker range="<=vs-2019"
574
+
575
+
|Function signature|Description|
576
+
|------------------------|-----------------|
577
+
|`GetTargetFrameworkIdentifier(string targetFramework)`|Parse the TargetFrameworkIdentifier from the TargetFramework.|
578
+
|`GetTargetFrameworkVersion(string targetFramework, int versionPartCount)`|Parse the TargetFrameworkVersion from the TargetFramework.|
579
+
|`GetTargetPlatformIdentifier(string targetFramework)`|Parse the TargetPlatformIdentifier from the TargetFramework.|
580
+
|`GetTargetPlatformVersion(string targetFramework, int versionPartCount)`|Parse the TargetPlatformVersion from the TargetFramework.|
581
+
|`IsTargetFrameworkCompatible(string targetFrameworkTarget, string targetFrameworkCandidate)`|Return 'True' if the candidate target framework (second argument) is compatible with the target framework indicated by the first argument, and false otherwise.|
582
+
:::moniker-end
510
583
511
584
The `versionPartCount` parameter of `GetTargetFrameworkVersion` and `GetTargetPlatformVersion` has a default value of 2.
512
585
@@ -547,12 +620,16 @@ Value6 = False
547
620
Value7 = False
548
621
```
549
622
623
+
::: moniker range=">=vs-2022"
624
+
550
625
### MSBuild FilterTargetFrameworks
551
626
552
627
With MSBuild 17.6 and later (or .NET 7 and later), you can use this property function to select a subset of a list of Target Framework Monikers (TFMs), to restrict the list to those frameworks that match the list of TFMs given the filter argument.
553
628
554
629
For example, if `incoming` is `net6.0;net7.0;netstandard2.0` and `filter` is `net7.0;netstandard2.0`, the result is `net7.0;netstandard2.0`.
555
630
631
+
::: moniker-end
632
+
556
633
## MSBuild version-comparison functions
557
634
558
635
MSBuild 16.5 and higher define several functions for comparing strings that represent versions.
0 commit comments