Skip to content

Commit

Permalink
only report dependencies whose version numbers can be resolved (#9387)
Browse files Browse the repository at this point in the history
  • Loading branch information
brettfo authored Apr 2, 2024
1 parent 30b8dd0 commit 1fc9a86
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2528,5 +2528,35 @@ await TestUpdateForProject("Newtonsoft.Json", "7.0.1", "13.0.1",
"""
);
}

[Fact]
public async Task UnresolvablePropertyDoesNotStopOtherUpdates()
{
// the property `$(MauiVersion)` cannot be resolved
await TestUpdateForProject("Newtonsoft.Json", "7.0.1", "13.0.1",
projectContents: """
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Newtonsoft.Json" Version="7.0.1" />
</ItemGroup>
</Project>
""",
expectedProjectContents: """
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
</Project>
"""
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ public static IEnumerable<Dependency> GetTopLevelPackageDependencyInfos(Immutabl
var evaluationResult = GetEvaluatedValue(packageVersion, propertyInfo);
if (evaluationResult.ResultType != EvaluationResultType.Success)
{
throw new InvalidDataException(evaluationResult.ErrorMessage);
// if we can't resolve the package version, don't report the dependency
continue;
}

packageVersion = evaluationResult.EvaluatedValue.TrimStart('[', '(').TrimEnd(']', ')');
Expand Down

0 comments on commit 1fc9a86

Please sign in to comment.