Update analysis to account for non-shipping package references (samples, tests)
This commit is contained in:
parent
479e37d7cc
commit
7568441acc
|
|
@ -51,7 +51,7 @@
|
||||||
|
|
||||||
<Target Name="CloneRepositories" DependsOnTargets="_PrepareRepositories">
|
<Target Name="CloneRepositories" DependsOnTargets="_PrepareRepositories">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<_CloneRepositories Include="@(Repository);@(VerifyRepository)" />
|
<_CloneRepositories Include="@(Repository);@(ShippedRepository)" />
|
||||||
<_CloneRepository Include="$(MSBuildProjectFullPath)">
|
<_CloneRepository Include="$(MSBuildProjectFullPath)">
|
||||||
<AdditionalProperties>
|
<AdditionalProperties>
|
||||||
CloneRepository=%(_CloneRepositories.Identity);
|
CloneRepository=%(_CloneRepositories.Identity);
|
||||||
|
|
@ -123,9 +123,19 @@
|
||||||
<Output TaskParameter="TargetOutputs" ItemName="Solution" />
|
<Output TaskParameter="TargetOutputs" ItemName="Solution" />
|
||||||
</MSBuild>
|
</MSBuild>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Analyze what was shipped in these repos.
|
||||||
|
This is required so we can verify that cascading versions are consistent.
|
||||||
|
-->
|
||||||
|
<MSBuild Projects="$(MSBuildProjectFullPath)"
|
||||||
|
Targets="GetArtifactInfo"
|
||||||
|
Properties="RepositoryRoot=$(_CloneRepositoryRoot)%(ShippedRepository.Identity)\;Configuration=$(Configuration);BuildNumber=$(BuildNumber);IsFinalBuild=true"
|
||||||
|
ContinueOnError="WarnAndContinue">
|
||||||
|
<Output TaskParameter="TargetOutputs" ItemName="ShippedArtifactInfo" />
|
||||||
|
</MSBuild>
|
||||||
<MSBuild Projects="$(MSBuildProjectFullPath)"
|
<MSBuild Projects="$(MSBuildProjectFullPath)"
|
||||||
Targets="ResolveSolutions"
|
Targets="ResolveSolutions"
|
||||||
Properties="RepositoryRoot=$(_CloneRepositoryRoot)%(VerifyRepository.Identity)\;Configuration=$(Configuration);BuildNumber=$(BuildNumber)"
|
Properties="RepositoryRoot=$(_CloneRepositoryRoot)%(ShippedRepository.Identity)\;Configuration=$(Configuration);BuildNumber=$(BuildNumber)"
|
||||||
ContinueOnError="WarnAndContinue">
|
ContinueOnError="WarnAndContinue">
|
||||||
<Output TaskParameter="TargetOutputs" ItemName="_NoBuildSolution" />
|
<Output TaskParameter="TargetOutputs" ItemName="_NoBuildSolution" />
|
||||||
</MSBuild>
|
</MSBuild>
|
||||||
|
|
@ -143,6 +153,7 @@
|
||||||
<RepoTasks.AnalyzeBuildGraph
|
<RepoTasks.AnalyzeBuildGraph
|
||||||
Solutions="@(Solution)"
|
Solutions="@(Solution)"
|
||||||
Artifacts="@(ArtifactInfo)"
|
Artifacts="@(ArtifactInfo)"
|
||||||
|
ShippedArtifacts="@(ShippedArtifactInfo)"
|
||||||
Properties="Configuration=$(Configuration);BuildNumber=$(BuildNumber)">
|
Properties="Configuration=$(Configuration);BuildNumber=$(BuildNumber)">
|
||||||
<Output TaskParameter="RepositoryBuildOrder" ItemName="RepositoryBuildOrder" />
|
<Output TaskParameter="RepositoryBuildOrder" ItemName="RepositoryBuildOrder" />
|
||||||
</RepoTasks.AnalyzeBuildGraph>
|
</RepoTasks.AnalyzeBuildGraph>
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,10 @@ namespace RepoTasks
|
||||||
[Required]
|
[Required]
|
||||||
public ITaskItem[] Artifacts { get; set; }
|
public ITaskItem[] Artifacts { get; set; }
|
||||||
|
|
||||||
|
// Artifacts that already shipped from repos
|
||||||
|
[Required]
|
||||||
|
public ITaskItem[] ShippedArtifacts { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public string Properties { get; set; }
|
public string Properties { get; set; }
|
||||||
|
|
||||||
|
|
@ -83,10 +87,17 @@ namespace RepoTasks
|
||||||
|
|
||||||
private void EnsureConsistentGraph(IEnumerable<ArtifactInfo.Package> packages, IEnumerable<SolutionInfo> solutions)
|
private void EnsureConsistentGraph(IEnumerable<ArtifactInfo.Package> packages, IEnumerable<SolutionInfo> solutions)
|
||||||
{
|
{
|
||||||
|
var shippedPackageMap = ShippedArtifacts
|
||||||
|
.Select(ArtifactInfo.Parse)
|
||||||
|
.OfType<ArtifactInfo.Package>()
|
||||||
|
.Where(p => !p.IsSymbolsArtifact)
|
||||||
|
.ToDictionary(p => p.PackageInfo.Id, p => p, StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
// ensure versions cascade
|
// ensure versions cascade
|
||||||
var lookup = packages.ToDictionary(p => p.PackageInfo.Id, p => p, StringComparer.OrdinalIgnoreCase);
|
var buildPackageMap = packages.ToDictionary(p => p.PackageInfo.Id, p => p, StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
var inconsistentVersions = new List<VersionMismatch>();
|
var inconsistentVersions = new List<VersionMismatch>();
|
||||||
|
var reposThatShouldPatch = new HashSet<string>();
|
||||||
|
|
||||||
// holy crap, o^4
|
// holy crap, o^4
|
||||||
foreach (var sln in solutions)
|
foreach (var sln in solutions)
|
||||||
|
|
@ -94,7 +105,7 @@ namespace RepoTasks
|
||||||
foreach (var tfm in proj.Frameworks)
|
foreach (var tfm in proj.Frameworks)
|
||||||
foreach (var dependency in tfm.Dependencies)
|
foreach (var dependency in tfm.Dependencies)
|
||||||
{
|
{
|
||||||
if (!lookup.TryGetValue(dependency.Key, out var package)) continue;
|
if (!buildPackageMap.TryGetValue(dependency.Key, out var package)) continue;
|
||||||
|
|
||||||
var refVersion = VersionRange.Parse(dependency.Value.Version);
|
var refVersion = VersionRange.Parse(dependency.Value.Version);
|
||||||
if (refVersion.IsFloating && refVersion.Float.Satisfies(package.PackageInfo.Version))
|
if (refVersion.IsFloating && refVersion.Float.Satisfies(package.PackageInfo.Version))
|
||||||
|
|
@ -102,6 +113,19 @@ namespace RepoTasks
|
||||||
else if (package.PackageInfo.Version.Equals(refVersion))
|
else if (package.PackageInfo.Version.Equals(refVersion))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (!sln.ShouldBuild)
|
||||||
|
{
|
||||||
|
if (!shippedPackageMap.TryGetValue(proj.PackageId, out _))
|
||||||
|
{
|
||||||
|
Log.LogMessage(MessageImportance.Normal, $"Detected inconsistent in a sample or test project {proj.FullPath}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reposThatShouldPatch.Add(Path.GetFileName(Path.GetDirectoryName(sln.FullPath)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inconsistentVersions.Add(new VersionMismatch
|
inconsistentVersions.Add(new VersionMismatch
|
||||||
{
|
{
|
||||||
Solution = sln,
|
Solution = sln,
|
||||||
|
|
@ -119,13 +143,13 @@ namespace RepoTasks
|
||||||
sb.AppendLine($"Repos are inconsistent. The following projects have PackageReferences that should be updated");
|
sb.AppendLine($"Repos are inconsistent. The following projects have PackageReferences that should be updated");
|
||||||
foreach (var sln in inconsistentVersions.GroupBy(p => p.Solution.FullPath))
|
foreach (var sln in inconsistentVersions.GroupBy(p => p.Solution.FullPath))
|
||||||
{
|
{
|
||||||
sb.AppendLine($" - {Path.GetFileName(sln.Key)}");
|
sb.Append(" - ").AppendLine(Path.GetFileName(sln.Key));
|
||||||
foreach (var proj in sln.GroupBy(p => p.Project.FullPath))
|
foreach (var proj in sln.GroupBy(p => p.Project.FullPath))
|
||||||
{
|
{
|
||||||
sb.AppendLine($" - {Path.GetFileName(proj.Key)}");
|
sb.Append(" - ").AppendLine(Path.GetFileName(proj.Key));
|
||||||
foreach (var m in proj)
|
foreach (var m in proj)
|
||||||
{
|
{
|
||||||
sb.AppendLine($" - {m.PackageId}/{{{m.ActualVersion} => {m.ExpectedVersion}}}");
|
sb.AppendLine($" + {m.PackageId}/{{{m.ActualVersion} => {m.ExpectedVersion}}}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -133,6 +157,11 @@ namespace RepoTasks
|
||||||
Log.LogMessage(MessageImportance.High, sb.ToString());
|
Log.LogMessage(MessageImportance.High, sb.ToString());
|
||||||
Log.LogError("Package versions are inconsistent. See build log for details.");
|
Log.LogError("Package versions are inconsistent. See build log for details.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var repo in reposThatShouldPatch)
|
||||||
|
{
|
||||||
|
Log.LogError($"{repo} should not be a 'ShippedRepository'. Version changes in other repositories mean it should be patched to perserve cascading version upgrades.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ITaskItem[] GetRepositoryBuildOrder(IEnumerable<ArtifactInfo.Package> artifacts, IEnumerable<SolutionInfo> solutions)
|
private ITaskItem[] GetRepositoryBuildOrder(IEnumerable<ArtifactInfo.Package> artifacts, IEnumerable<SolutionInfo> solutions)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue