dotnet / dotnet/msbuild

[BuildCheck Suggestion]: Detect and flag usage of the `$(OS)` MSBuild Property

Open
#10,707 0 comments 0 reactions 0 assignees View on GitHub
Area: BuildCheck BuildCheck Suggestion Priority:3 triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

### Summary

This property only has two documented values, "Windows_NT" and "Unix", but this doesn't tell the story accurately today. In addition, this property like all properties can be overridden by environment variables. We should guide users to better-supported mechanisms for determining the OS of the executing build. Users should use the static members of the `System.OperatingSystem` like `IsWindows()` to check platform support.

### Background and Motivation

We don't have documented guidance for moving away from `$(OS)`, this should help drive that as well.

### Sample issue or antipattern that the check should be flagging

This

```
dotnet
dotnet.exe
```

should suggest using

```
dotnet
dotnet.exe
```

instead

### Sample output

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.