Skip to content

Commit 20f795c

Browse files
committed
Code quality improvements
1 parent 50f9354 commit 20f795c

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Semmle.Autobuild.CSharp
2+
{
3+
internal static class Constants
4+
{
5+
// The version number should be kept in sync with the version .NET version used for building the application.
6+
public const string LatestDotNetSdkVersion = "8.0.101";
7+
}
8+
}

csharp/autobuilder/Semmle.Autobuild.CSharp/DotNetRule.cs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,27 +85,23 @@ public static BuildScript WithDotNet(IAutobuilder<AutobuildOptionsShared> builde
8585
var installScript = DownloadDotNet(builder, installDir, ensureDotNetAvailable);
8686
return BuildScript.Bind(installScript, installed =>
8787
{
88-
Dictionary<string, string>? env;
88+
var env = new Dictionary<string, string>
89+
{
90+
{ "DOTNET_SKIP_FIRST_TIME_EXPERIENCE", "true" },
91+
{ "MSBUILDDISABLENODEREUSE", "1" }
92+
};
8993
if (installed == 0)
9094
{
9195
// The installation succeeded, so use the newly installed .NET Core
9296
var path = builder.Actions.GetEnvironmentVariable("PATH");
9397
var delim = builder.Actions.IsWindows() ? ";" : ":";
94-
env = new Dictionary<string, string>{
95-
{ "DOTNET_MULTILEVEL_LOOKUP", "false" }, // prevent look up of other .NET Core SDKs
96-
{ "DOTNET_SKIP_FIRST_TIME_EXPERIENCE", "true" },
97-
{ "MSBUILDDISABLENODEREUSE", "1" },
98-
{ "PATH", installDir + delim + path }
99-
};
98+
env.Add("DOTNET_MULTILEVEL_LOOKUP", "false"); // prevent look up of other .NET Core SDKs
99+
env.Add("PATH", installDir + delim + path);
100100
}
101101
else
102102
{
103103
// The .NET SDK was not installed, either because the installation failed or because it was already installed.
104104
installDir = null;
105-
env = new Dictionary<string, string> {
106-
{ "DOTNET_SKIP_FIRST_TIME_EXPERIENCE", "true" },
107-
{ "MSBUILDDISABLENODEREUSE", "1" }
108-
};
109105
}
110106

111107
return f(installDir, env);
@@ -163,8 +159,7 @@ private static BuildScript DownloadDotNet(IAutobuilder<AutobuildOptionsShared> b
163159

164160
if (ensureDotNetAvailable)
165161
{
166-
const string latestDotNetSdkVersion = "8.0.101";
167-
return DownloadDotNetVersion(builder, installDir, latestDotNetSdkVersion, needExactVersion: false);
162+
return DownloadDotNetVersion(builder, installDir, Constants.LatestDotNetSdkVersion, needExactVersion: false);
168163
}
169164

170165
return BuildScript.Failure;

csharp/autobuilder/Semmle.Autobuild.CSharp/StandaloneBuildRule.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ internal StandaloneBuildRule(string? dotNetPath)
1616

1717
public BuildScript Analyse(IAutobuilder<CSharpAutobuildOptions> builder, bool auto)
1818
{
19-
if (!builder.Options.Buildless
20-
|| builder.CodeQLExtractorLangRoot is null
19+
if (builder.CodeQLExtractorLangRoot is null
2120
|| builder.CodeQlPlatform is null)
2221
{
2322
return BuildScript.Failure;

0 commit comments

Comments
 (0)