mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Minor improvement to not start dotnet process when it is known to fail
This commit is contained in:
@@ -611,8 +611,6 @@ namespace Semmle.Autobuild.CSharp.Tests
|
||||
{
|
||||
actions.RunProcess["dotnet --info"] = 1;
|
||||
actions.RunProcessOut["dotnet --info"] = "";
|
||||
actions.RunProcess["dotnet --list-sdks"] = 1;
|
||||
actions.RunProcessOut["dotnet --list-sdks"] = "";
|
||||
actions.RunProcess[@"chmod u+x scratch/.dotnet/dotnet-install.sh"] = 0;
|
||||
actions.RunProcess[@"scratch/.dotnet/dotnet-install.sh --channel release --version 8.0.101 --install-dir scratch/.dotnet"] = 0;
|
||||
actions.RunProcess[@"C:\codeql\csharp/tools/linux64/Semmle.Extraction.CSharp.Standalone --dotnet scratch/.dotnet"] = 0;
|
||||
@@ -626,7 +624,7 @@ namespace Semmle.Autobuild.CSharp.Tests
|
||||
actions.CreateDirectories.Add(@"scratch/.dotnet");
|
||||
|
||||
var autobuilder = CreateAutoBuilder(false, buildless: "true");
|
||||
TestAutobuilderScript(autobuilder, 0, 5);
|
||||
TestAutobuilderScript(autobuilder, 0, 4);
|
||||
}
|
||||
|
||||
private void SkipVsWhere()
|
||||
|
||||
@@ -172,7 +172,7 @@ namespace Semmle.Autobuild.CSharp
|
||||
|
||||
const string latestDotNetSdkVersion = "8.0.101";
|
||||
builder.Log(Severity.Info, $"No .NET Core SDK found. Attempting to install version {latestDotNetSdkVersion}.");
|
||||
return DownloadDotNetVersion(builder, installDir, latestDotNetSdkVersion);
|
||||
return DownloadDotNetVersion(builder, installDir, latestDotNetSdkVersion, checkInstalledSdkVersion: false);
|
||||
});
|
||||
|
||||
}
|
||||
@@ -186,14 +186,20 @@ namespace Semmle.Autobuild.CSharp
|
||||
///
|
||||
/// See https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script.
|
||||
/// </summary>
|
||||
private static BuildScript DownloadDotNetVersion(IAutobuilder<AutobuildOptionsShared> builder, string path, string version)
|
||||
private static BuildScript DownloadDotNetVersion(IAutobuilder<AutobuildOptionsShared> builder, string path, string version, bool checkInstalledSdkVersion = true)
|
||||
{
|
||||
return BuildScript.Bind(GetInstalledSdksScript(builder.Actions), (sdks, sdksRet) =>
|
||||
var firstScript = checkInstalledSdkVersion
|
||||
? GetInstalledSdksScript(builder.Actions)
|
||||
: BuildScript.Success;
|
||||
|
||||
return BuildScript.Bind(firstScript, (sdks, sdksRet) =>
|
||||
{
|
||||
if (sdksRet == 0 && sdks.Count == 1 && sdks[0].StartsWith(version + " ", StringComparison.Ordinal))
|
||||
if (checkInstalledSdkVersion && sdksRet == 0 && sdks.Count == 1 && sdks[0].StartsWith(version + " ", StringComparison.Ordinal))
|
||||
{
|
||||
// The requested SDK is already installed (and no other SDKs are installed), so
|
||||
// no need to reinstall
|
||||
return BuildScript.Failure;
|
||||
}
|
||||
|
||||
builder.Log(Severity.Info, "Attempting to download .NET Core {0}", version);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user