Skip to content

Commit 5a5fc79

Browse files
committed
Fix regex to recognize prerelease version string
1 parent 9926c81 commit 5a5fc79

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -491,14 +491,10 @@ private RestoreResult TryRestorePackageManually(string package, string? nugetCon
491491
if (!res.Success && tryPrereleaseVersion && res.HasNugetNoStablePackageVersionError)
492492
{
493493
logger.LogDebug($"Failed to restore nuget package {package} because no stable version was found.");
494-
try
495-
{
496-
TryChangePackageVersion(tempDir.DirInfo, "*-*");
494+
TryChangePackageVersion(tempDir.DirInfo, "*-*");
497495

498-
res = dotnet.Restore(new(tempDir.DirInfo.FullName, missingPackageDirectory.DirInfo.FullName, ForceDotnetRefAssemblyFetching: false, PathToNugetConfig: nugetConfig, ForceReevaluation: true));
499-
return res;
500-
}
501-
finally
496+
res = dotnet.Restore(new(tempDir.DirInfo.FullName, missingPackageDirectory.DirInfo.FullName, ForceDotnetRefAssemblyFetching: false, PathToNugetConfig: nugetConfig, ForceReevaluation: true));
497+
if (!res.Success)
502498
{
503499
TryChangePackageVersion(tempDir.DirInfo, "*");
504500
}
@@ -729,7 +725,7 @@ private IEnumerable<string> GetFeeds(Func<IList<string>> getNugetFeeds)
729725
[GeneratedRegex(@"<TargetFramework>.*</TargetFramework>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)]
730726
private static partial Regex TargetFramework();
731727

732-
[GeneratedRegex(@"Version=""[*|*-*]""", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)]
728+
[GeneratedRegex(@"Version=""(\*|\*-\*)""", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)]
733729
private static partial Regex PackageReferenceVersion();
734730

735731
[GeneratedRegex(@"^(.+)\.(\d+\.\d+\.\d+(-(.+))?)$", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline)]

0 commit comments

Comments
 (0)