-
Notifications
You must be signed in to change notification settings - Fork 1.8k
C#: Improve the logic for downloading .NET and setting environment variables. #20837
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
Changes from all commits
7d746d4
d7545f2
ed92352
8df57d8
0daee6f
fba496f
34de2f5
edabbfc
5cdfb3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| using System.Collections.Generic; | ||
| using System.Collections.ObjectModel; | ||
|
|
||
| namespace Semmle.Extraction.CSharp.DependencyFetching | ||
| { | ||
|
|
@@ -9,6 +10,20 @@ internal interface IDotNetCliInvoker | |
| /// </summary> | ||
| string Exec { get; } | ||
|
|
||
| /// <summary> | ||
| /// A minimal environment for running the .NET CLI. | ||
| /// | ||
| /// DOTNET_CLI_UI_LANGUAGE: The .NET CLI language is set to English to avoid localized output. | ||
| /// MSBUILDDISABLENODEREUSE: To ensure clean environment for each build. | ||
| /// DOTNET_SKIP_FIRST_TIME_EXPERIENCE: To skip first time experience messages. | ||
| /// </summary> | ||
| static ReadOnlyDictionary<string, string> MinimalEnvironment { get; } = new(new Dictionary<string, string> | ||
| { | ||
| {"DOTNET_CLI_UI_LANGUAGE", "en"}, | ||
| {"MSBUILDDISABLENODEREUSE", "1"}, | ||
| {"DOTNET_SKIP_FIRST_TIME_EXPERIENCE", "true"} | ||
|
Comment on lines
+22
to
+24
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: The doc comment above explains
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was no comment explaining this before and I just moved the logic.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will add some comments - then the tests will also be run a again 😄 |
||
| }); | ||
|
|
||
| /// <summary> | ||
| /// Execute `dotnet <paramref name="args"/>` and return true if the command succeeded, otherwise false. | ||
| /// If `silent` is true the output of the command is logged as `debug` otherwise as `info`. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "sdk": { | ||
| "version": "10.0.100" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| def test1(codeql, csharp): | ||
| codeql.database.create() | ||
|
|
||
| def test2(codeql, csharp): | ||
| codeql.database.create(build_mode="none") |
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.
Drive-by comment: does this not cause problems for the tracer? I assume some test would have caught it if it was a problem, but I am curious about why this is OK. Would it maybe make sense to document that in a comment here?
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.
On the ARM machines (when inspecting the output from the other tests) it looks like the RiD is
osx-arm64for the installed .NET versions (at least those being used). Without setting this explicitly, the install script downloads theosx-x64version. According to CoPilot it can cause problems when different versions of .NET are installed on the same machine. Changing this appears to have a positive effect when running the (traced .NET 10) tests on the MacOS 15 and MacOS26 runners.