diff --git a/Universe.sln b/Universe.sln
deleted file mode 100644
index d1dd9a12a5..0000000000
--- a/Universe.sln
+++ /dev/null
@@ -1,27 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.26228.0
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PinVersions", "tools\PinVersions\PinVersions.csproj", "{DACA9DFB-508E-45EA-A5CF-C0F5C2BA181B}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "shared", "shared", "{085280EC-7055-426A-BF9C-1B692B9599AB}"
- ProjectSection(SolutionItems) = preProject
- tools\shared\DependencyGraphSpecProvider.cs = tools\shared\DependencyGraphSpecProvider.cs
- EndProjectSection
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {DACA9DFB-508E-45EA-A5CF-C0F5C2BA181B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {DACA9DFB-508E-45EA-A5CF-C0F5C2BA181B}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {DACA9DFB-508E-45EA-A5CF-C0F5C2BA181B}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {DACA9DFB-508E-45EA-A5CF-C0F5C2BA181B}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/build/Repositories.props b/build/Repositories.props
index 6ec2904fe3..1bdfb82212 100644
--- a/build/Repositories.props
+++ b/build/Repositories.props
@@ -1,10 +1,7 @@
-
-
-
-
+
@@ -13,6 +10,9 @@
Build tools will *verify* that these repos will be unaffected
by the patch update and do not need updating.
-->
+
+
+
diff --git a/build/RepositoryBuild.targets b/build/RepositoryBuild.targets
index 52fe532c38..eb6e75b617 100644
--- a/build/RepositoryBuild.targets
+++ b/build/RepositoryBuild.targets
@@ -41,20 +41,14 @@
-
-
- <_KorebuildItems Include="$(RepositoryRoot).build\**\*.*" />
-
-
-
-
+
+
+
+ WorkingDirectory="$(RepositoryRoot)" />
@@ -71,24 +65,19 @@
SourceFiles="@(RepositoryMSBuildArtifacts)"
DestinationFolder="$(ArtifactsDir)msbuild\$(RepositoryToBuild)\%(RecursiveDir)" />
-
-
-
-
-
+
+
+
+
+
-
- $(RepositoryRoot)tools\PinVersions\bin\$(Configuration)\netcoreapp1.1\PinVersions.dll
- $(DotNetPath) $(PinToolBinary) --graph-specs-root "$(_RestoreGraphSpecsDirectory) " -s "$(BuildDir) " "$(BuildRepositoryRoot) "
- $(PinVersionArgs) -s "$(_DependencyPackagesDirectory) "
-
-
-
+
-
\ No newline at end of file
+
+
diff --git a/build/repo.props b/build/repo.props
new file mode 100644
index 0000000000..844540c47a
--- /dev/null
+++ b/build/repo.props
@@ -0,0 +1,6 @@
+
+
+
+ true
+
+
diff --git a/build/repo.targets b/build/repo.targets
index 5d67fafd0d..9dc8fdd308 100644
--- a/build/repo.targets
+++ b/build/repo.targets
@@ -23,10 +23,6 @@
$(BuildDependsOn);CloneRepositories;BuildRepositories
-
-
-
-
@@ -57,7 +53,7 @@
- <_CloneRepositories Include="@(Repository);@(VerifyRepositories)" />
+ <_CloneRepositories Include="@(Repository);@(VerifyRepository)" />
<_CloneRepository Include="$(MSBuildProjectFullPath)">
CloneRepository=%(_CloneRepositories.Identity);
@@ -122,7 +118,7 @@
+ DependsOnTargets="_PrepareRepositories;_CreateRepositoriesListWithCommits;_UpdateNuGetConfig;_GenerateBuildGraph;_BuildRepositories" />
@@ -213,9 +209,4 @@
-
-
-
-
-
diff --git a/build/tasks/BuildGraph/DependencyGraphSpecProvider.cs b/build/tasks/BuildGraph/DependencyGraphSpecProvider.cs
index 805033c1c2..d16600578a 100644
--- a/build/tasks/BuildGraph/DependencyGraphSpecProvider.cs
+++ b/build/tasks/BuildGraph/DependencyGraphSpecProvider.cs
@@ -1,3 +1,6 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
using System.IO;
using NuGet.ProjectModel;
@@ -15,6 +18,12 @@ namespace RepoTools.BuildGraph
public DependencyGraphSpec GetDependencyGraphSpec(string repositoryName, string solutionPath)
{
var outputFile = Path.Combine(_packageSpecDirectory, repositoryName, Path.GetFileName(solutionPath) + ".json");
+
+ if (!File.Exists(outputFile))
+ {
+ return null;
+ }
+
return DependencyGraphSpec.Load(outputFile);
}
}
diff --git a/build/tasks/BuildGraph/GraphBuilder.cs b/build/tasks/BuildGraph/GraphBuilder.cs
index 8199335433..d70b1ba45d 100644
--- a/build/tasks/BuildGraph/GraphBuilder.cs
+++ b/build/tasks/BuildGraph/GraphBuilder.cs
@@ -1,12 +1,17 @@
-using System;
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
+using Microsoft.Build.Utilities;
namespace RepoTools.BuildGraph
{
public static class GraphBuilder
{
- public static IList Generate(IList repositories, string root)
+ public static IList Generate(IList repositories, string root, TaskLoggingHelper log)
{
// Build global list of primary projects
var primaryProjects = repositories.SelectMany(c => c.Projects)
@@ -31,7 +36,15 @@ namespace RepoTools.BuildGraph
var dependencyRepository = dependencyProject.Repository;
var dependencyNode = graphNodes[dependencyRepository];
- thisProjectRepositoryNode.Incoming.Add(dependencyNode);
+ if (ReferenceEquals(thisProjectRepositoryNode, dependencyNode))
+ {
+ log.LogWarning("{0} has a package reference to a package produced in the same repo. {1} -> {2}", project.Repository.Name, Path.GetFileName(project.Path), packageDependency);
+ }
+ else
+ {
+ thisProjectRepositoryNode.Incoming.Add(dependencyNode);
+ }
+
dependencyNode.Outgoing.Add(thisProjectRepositoryNode);
}
}
diff --git a/build/tasks/BuildGraph/GraphNode.cs b/build/tasks/BuildGraph/GraphNode.cs
index 8c2a023ab2..b7197e8b38 100644
--- a/build/tasks/BuildGraph/GraphNode.cs
+++ b/build/tasks/BuildGraph/GraphNode.cs
@@ -1,4 +1,7 @@
-using System.Collections.Generic;
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System.Collections.Generic;
using System.Diagnostics;
namespace RepoTools.BuildGraph
diff --git a/build/tasks/BuildGraph/Project.cs b/build/tasks/BuildGraph/Project.cs
index 10a821a336..72b5eee254 100644
--- a/build/tasks/BuildGraph/Project.cs
+++ b/build/tasks/BuildGraph/Project.cs
@@ -1,4 +1,7 @@
-using System;
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -14,6 +17,8 @@ namespace RepoTools.BuildGraph
public string Name { get; }
+ public string Version { get; set; }
+
public string Path { get; set; }
public Repository Repository { get; set; }
diff --git a/build/tasks/BuildGraph/Repository.cs b/build/tasks/BuildGraph/Repository.cs
index c71ade8555..c1e3e5c619 100644
--- a/build/tasks/BuildGraph/Repository.cs
+++ b/build/tasks/BuildGraph/Repository.cs
@@ -1,4 +1,7 @@
-using System;
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
@@ -49,6 +52,7 @@ namespace RepoTools.BuildGraph
var repository = new Repository(name);
ReadSharedSourceProjects(Path.Combine(repositoryPath, "shared"), repository, repository.Projects);
+
var srcDirectory = Path.GetFullPath(Path.Combine(repositoryPath, "src"))
.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
@@ -56,6 +60,11 @@ namespace RepoTools.BuildGraph
foreach (var file in solutionFiles)
{
var spec = provider.GetDependencyGraphSpec(name, file);
+ if (spec == null)
+ {
+ continue;
+ }
+
var projects = spec.Projects.OrderBy(p => p.RestoreMetadata.ProjectStyle == ProjectStyle.PackageReference ? 0 : 1);
foreach (var specProject in projects)
{
@@ -73,6 +82,7 @@ namespace RepoTools.BuildGraph
{
Repository = repository,
Path = specProject.FilePath,
+ Version = specProject.Version?.ToString(),
};
projectGroup.Add(project);
diff --git a/build/tasks/BuildGraph/TopologicalSort.cs b/build/tasks/BuildGraph/TopologicalSort.cs
index 4d362be3e4..161a9913d7 100644
--- a/build/tasks/BuildGraph/TopologicalSort.cs
+++ b/build/tasks/BuildGraph/TopologicalSort.cs
@@ -1,4 +1,7 @@
-using System;
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/build/tasks/BuildGraph/CalculateBuildGraph.cs b/build/tasks/CalculateBuildGraph.cs
similarity index 88%
rename from build/tasks/BuildGraph/CalculateBuildGraph.cs
rename to build/tasks/CalculateBuildGraph.cs
index 6e1dc6de2b..9475bd99ec 100644
--- a/build/tasks/BuildGraph/CalculateBuildGraph.cs
+++ b/build/tasks/CalculateBuildGraph.cs
@@ -15,19 +15,19 @@ namespace RepoTasks
[Required]
public ITaskItem[] Repositories { get; set; }
- [Output]
- public ITaskItem[] RepositoriesToBuildInOrder { get; set; }
+ ///
+ /// Directory that contains the package spec files.
+ ///
+ [Required]
+ public string PackageSpecsDirectory { get; set; }
///
/// The repository at which to root the graph at
///
public string StartGraphAt { get; set; }
- ///
- /// Directory that contains the package spec files.
- ///
- [Required]
- public string PackageSpecsDirectory { get; set; }
+ [Output]
+ public ITaskItem[] RepositoriesToBuildInOrder { get; set; }
public override bool Execute()
{
@@ -36,12 +36,18 @@ namespace RepoTasks
var repositoryPaths = Repositories.Select(r => r.GetMetadata("RepositoryPath")).ToList();
var repositories = Repository.ReadAllRepositories(repositoryPaths, graphSpecProvider);
- var graph = GraphBuilder.Generate(repositories, StartGraphAt);
+ var graph = GraphBuilder.Generate(repositories, StartGraphAt, Log);
var repositoriesWithOrder = new List<(ITaskItem repository, int order)>();
foreach (var repositoryTaskItem in Repositories)
{
var repositoryName = repositoryTaskItem.ItemSpec;
- var graphNodeRepository = graph.First(g => g.Repository.Name == repositoryName);
+ var graphNodeRepository = graph.FirstOrDefault(g => g.Repository.Name == repositoryName);
+ if (graphNodeRepository == null)
+ {
+ // StartGraphAt was specified so the graph is incomplete.
+ continue;
+ }
+
var order = TopologicalSort.GetOrder(graphNodeRepository);
repositoryTaskItem.SetMetadata("Order", order.ToString());
repositoriesWithOrder.Add((repositoryTaskItem, order));
diff --git a/build/tasks/Logger/FlowLogger.cs b/build/tasks/Logger/FlowLogger.cs
new file mode 100644
index 0000000000..e6a214fdff
--- /dev/null
+++ b/build/tasks/Logger/FlowLogger.cs
@@ -0,0 +1,61 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using System.Linq;
+using Microsoft.Build.Framework;
+using Microsoft.Build.Logging;
+
+namespace RepoTasks
+{
+ public class FlowLogger : ConsoleLogger
+ {
+ private volatile bool _initialized;
+
+ public FlowLogger()
+ {
+ }
+
+ public override void Initialize(IEventSource eventSource, int nodeCount)
+ {
+ PreInit(eventSource);
+ base.Initialize(eventSource, nodeCount);
+ }
+
+ public override void Initialize(IEventSource eventSource)
+ {
+ PreInit(eventSource);
+ base.Initialize(eventSource);
+ }
+
+ private void PreInit(IEventSource eventSource)
+ {
+ if (_initialized) return;
+ _initialized = true;
+
+ var flowId = GetFlowId();
+ var prefix = $"{flowId,-22}| ";
+ var write = WriteHandler;
+ WriteHandler = msg => write(prefix + msg);
+
+ eventSource.BuildStarted += (o, e) =>
+ {
+ WriteHandler(e.Message + Environment.NewLine);
+ };
+ }
+
+ private string GetFlowId()
+ {
+ var parameters = Parameters?.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
+ if (parameters == null || parameters.Length == 0)
+ {
+ return null;
+ }
+
+ const string flowIdParamName = "FlowId=";
+ return parameters
+ .FirstOrDefault(p => p.StartsWith(flowIdParamName, StringComparison.Ordinal))
+ ?.Substring(flowIdParamName.Length);
+ }
+ }
+}
diff --git a/build/tasks/PinVersions.cs b/build/tasks/PinVersions.cs
new file mode 100644
index 0000000000..b98c878173
--- /dev/null
+++ b/build/tasks/PinVersions.cs
@@ -0,0 +1,46 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using System.Linq;
+using Microsoft.Build.Framework;
+using RepoTasks.VersionPinning;
+
+namespace RepoTasks
+{
+ public class PinVersions : Microsoft.Build.Utilities.Task
+ {
+ [Required]
+ public string BuildRepositoryRoot { get; set; }
+
+ [Required]
+ public ITaskItem[] PackageSources { get; set; }
+
+ public string GraphSpecsRoot { get; set; }
+
+ public override bool Execute()
+ {
+ if (PackageSources?.Length == 0)
+ {
+ Log.LogError($"Missing PackageSources. At least one item source must be specified.");
+ return false;
+ }
+
+ var graphSpecProvider = !string.IsNullOrEmpty(GraphSpecsRoot)
+ ? new DependencyGraphSpecProvider(GraphSpecsRoot)
+ : DependencyGraphSpecProvider.Default;
+
+ using (graphSpecProvider)
+ {
+ var pinVersionUtility = new PinVersionUtility(
+ BuildRepositoryRoot,
+ PackageSources.Select(i => i.ItemSpec).ToList(),
+ graphSpecProvider,
+ Log);
+ pinVersionUtility.Execute();
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/build/tasks/RepoTasks.csproj b/build/tasks/RepoTasks.csproj
index d0f925d5d1..084b189145 100644
--- a/build/tasks/RepoTasks.csproj
+++ b/build/tasks/RepoTasks.csproj
@@ -6,7 +6,7 @@
-
+
diff --git a/build/tasks/RepoTasks.tasks b/build/tasks/RepoTasks.tasks
index dec196d939..0c188ffb1e 100644
--- a/build/tasks/RepoTasks.tasks
+++ b/build/tasks/RepoTasks.tasks
@@ -5,4 +5,5 @@
+
diff --git a/tools/shared/DependencyGraphSpecProvider.cs b/build/tasks/VersionPinning/DependencyGraphSpecProvider.cs
similarity index 86%
rename from tools/shared/DependencyGraphSpecProvider.cs
rename to build/tasks/VersionPinning/DependencyGraphSpecProvider.cs
index 4eb96e1234..1a5e2af362 100644
--- a/tools/shared/DependencyGraphSpecProvider.cs
+++ b/build/tasks/VersionPinning/DependencyGraphSpecProvider.cs
@@ -1,17 +1,19 @@
-using System;
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
-using Microsoft.DotNet.Cli.Utils;
using NuGet.ProjectModel;
-namespace UniverseTools
+namespace RepoTasks.VersionPinning
{
public class DependencyGraphSpecProvider : IDisposable
{
private readonly string _packageSpecDirectory;
private readonly bool _deleteSpecDirectoryOnDispose;
- private readonly string _muxerPath;
+ private readonly string _dotnetPath;
public DependencyGraphSpecProvider(string packageSpecDirectory)
: this(packageSpecDirectory, deleteSpecDirectoryOnDispose: false)
@@ -22,7 +24,7 @@ namespace UniverseTools
{
_packageSpecDirectory = packageSpecDirectory;
_deleteSpecDirectoryOnDispose = deleteSpecDirectoryOnDispose;
- _muxerPath = new Muxer().MuxerPath;
+ _dotnetPath = Process.GetCurrentProcess().MainModule.FileName;
}
public static DependencyGraphSpecProvider Default { get; } =
@@ -42,7 +44,7 @@ namespace UniverseTools
private void RunMSBuild(string solutionPath, string outputFile)
{
- var psi = new ProcessStartInfo(_muxerPath);
+ var psi = new ProcessStartInfo(_dotnetPath);
var arguments = new List
{
@@ -53,6 +55,7 @@ namespace UniverseTools
"/v:q",
"/p:BuildProjectReferences=false",
$"/p:RestoreGraphOutputPath=\"{outputFile}\"",
+ "/p:KoreBuildRestoreTargetsImported=true",
};
psi.Arguments = string.Join(" ", arguments);
diff --git a/tools/PinVersions/PinVersionUtility.cs b/build/tasks/VersionPinning/PinVersionUtility.cs
similarity index 69%
rename from tools/PinVersions/PinVersionUtility.cs
rename to build/tasks/VersionPinning/PinVersionUtility.cs
index 42d1e90176..c94e19fc62 100644
--- a/tools/PinVersions/PinVersionUtility.cs
+++ b/build/tasks/VersionPinning/PinVersionUtility.cs
@@ -1,4 +1,7 @@
-using System;
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
@@ -6,6 +9,8 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Linq;
+using Microsoft.Build.Framework;
+using Microsoft.Build.Utilities;
using NuGet.Common;
using NuGet.Frameworks;
using NuGet.LibraryModel;
@@ -13,19 +18,23 @@ using NuGet.ProjectModel;
using NuGet.Protocol;
using NuGet.Protocol.Core.Types;
using NuGet.Versioning;
-using UniverseTools;
-namespace PinVersions
+namespace RepoTasks.VersionPinning
{
- class PinVersionUtility
+ internal class PinVersionUtility
{
private readonly string _repositoryRoot;
private readonly FindPackageByIdResource[] _findPackageResources;
private readonly ConcurrentDictionary> _exactMatches = new ConcurrentDictionary>(StringComparer.OrdinalIgnoreCase);
private readonly DependencyGraphSpecProvider _provider;
private readonly SourceCacheContext _sourceCacheContext;
+ private readonly TaskLoggingHelper _logger;
- public PinVersionUtility(string repositoryRoot, List pinSources, DependencyGraphSpecProvider provider)
+ public PinVersionUtility(
+ string repositoryRoot,
+ List pinSources,
+ DependencyGraphSpecProvider provider,
+ TaskLoggingHelper logger)
{
_repositoryRoot = repositoryRoot;
_findPackageResources = new FindPackageByIdResource[pinSources.Count];
@@ -36,19 +45,27 @@ namespace PinVersions
}
_provider = provider;
_sourceCacheContext = new SourceCacheContext();
+ _logger = logger;
}
public void Execute()
{
- var solutionPinMetadata = GetPinVersionMetadata();
- foreach (var item in solutionPinMetadata)
+ _logger.LogMessage(MessageImportance.High, $"Pinning package references for projects in {_repositoryRoot}");
+
+ var solutionPinMetadata = GetProjectPinVersionMetadata();
+ foreach (var cliToolReference in solutionPinMetadata.CLIToolReferences)
+ {
+ _logger.LogMessage(MessageImportance.Normal, $"Pinning CLI Tool {cliToolReference.Item1.Name}({cliToolReference.Item1.VersionRange} to {cliToolReference.Item2} for all projects in {_repositoryRoot}.");
+ }
+
+ foreach (var item in solutionPinMetadata.PinVersionLookup)
{
var projectPinMetadata = item.Value;
var specProject = projectPinMetadata.PackageSpec;
- if (!(projectPinMetadata.Packages.Any() || projectPinMetadata.CLIToolReferences.Any()))
+ if (!(projectPinMetadata.Packages.Any() || solutionPinMetadata.CLIToolReferences.Any()))
{
- Console.WriteLine($"No package or tool references to pin for {specProject.FilePath}.");
+ _logger.LogMessage(MessageImportance.Normal, $"No package or tool references to pin for {specProject.FilePath}.");
continue;
}
@@ -59,12 +76,16 @@ namespace PinVersions
Directory.CreateDirectory(Path.GetDirectoryName(pinnedReferencesFile));
- Console.WriteLine($"Pinning package versions for {specProject.FilePath}.");
- var pinnedReferences = new XElement("ItemGroup");
+ if (projectPinMetadata.Packages.Any())
+ {
+ _logger.LogMessage(MessageImportance.Normal, $"Pinning package versions for {specProject.FilePath}.");
+ }
+
+ var pinnedReferences = new XElement("ItemGroup", new XAttribute("Condition", "'$(PolicyDesignTimeBuild)' != 'true' AND !Exists('$(MSBuildThisFileDirectory)$(MSBuildProjectFile).nugetpolicy.g.targets')"));
foreach (var packageReference in projectPinMetadata.Packages)
{
(var tfm, var libraryRange, var exactVersion) = packageReference;
- Console.WriteLine($"Pinning reference {libraryRange.Name}({libraryRange.VersionRange} to {exactVersion}.");
+ _logger.LogMessage(MessageImportance.Normal, $"Pinning reference {libraryRange.Name}({libraryRange.VersionRange} to {exactVersion}.");
var metadata = new List
{
new XAttribute("Update", libraryRange.Name),
@@ -79,10 +100,10 @@ namespace PinVersions
pinnedReferences.Add(new XElement("PackageReference", metadata));
}
- foreach (var toolReference in projectPinMetadata.CLIToolReferences)
+ // CLI Tool references are specified at solution level.
+ foreach (var toolReference in solutionPinMetadata.CLIToolReferences)
{
(var libraryRange, var exactVersion) = toolReference;
- Console.WriteLine($"Pinning CLI Tool {libraryRange.Name}({libraryRange.VersionRange} to {exactVersion}.");
var metadata = new List
{
new XAttribute("Update", libraryRange.Name),
@@ -97,10 +118,11 @@ namespace PinVersions
}
}
- private IDictionary GetPinVersionMetadata()
+ private SolutionPinVersionMetadata GetProjectPinVersionMetadata()
{
var repositoryDirectoryInfo = new DirectoryInfo(_repositoryRoot);
- var projects = new Dictionary(StringComparer.OrdinalIgnoreCase);
+ var projects = new Dictionary(StringComparer.OrdinalIgnoreCase);
+ var cliToolReferences = new List<(LibraryRange, NuGetVersion)>();
foreach (var slnFile in repositoryDirectoryInfo.EnumerateFiles("*.sln"))
{
@@ -109,7 +131,7 @@ namespace PinVersions
{
if (!projects.TryGetValue(specProject.FilePath, out var pinMetadata))
{
- pinMetadata = new PinVersionMetadata(specProject);
+ pinMetadata = new ProjectPinVersionMetadata(specProject);
projects[specProject.FilePath] = pinMetadata;
}
@@ -139,7 +161,7 @@ namespace PinVersions
}
else if (projectStyle == ProjectStyle.DotnetCliTool)
{
- pinMetadata.CLIToolReferences.Add((reference.LibraryRange, exactVersion));
+ cliToolReferences.Add((reference.LibraryRange, exactVersion));
}
else
{
@@ -149,7 +171,7 @@ namespace PinVersions
}
}
- return projects;
+ return new SolutionPinVersionMetadata(projects, cliToolReferences);
}
private NuGetVersion GetExactVersion(string name, VersionRange range)
@@ -188,20 +210,32 @@ namespace PinVersions
return null;
}
- private struct PinVersionMetadata
+ private struct SolutionPinVersionMetadata
{
- public PinVersionMetadata(PackageSpec packageSpec)
+ public SolutionPinVersionMetadata(
+ IDictionary pinVersionLookup,
+ List<(LibraryRange, NuGetVersion)> cliToolReferences)
+ {
+ PinVersionLookup = pinVersionLookup;
+ CLIToolReferences = cliToolReferences;
+ }
+
+ public IDictionary PinVersionLookup { get; }
+
+ public List<(LibraryRange, NuGetVersion)> CLIToolReferences { get; }
+ }
+
+ private struct ProjectPinVersionMetadata
+ {
+ public ProjectPinVersionMetadata(PackageSpec packageSpec)
{
PackageSpec = packageSpec;
Packages = new List<(NuGetFramework, LibraryRange, NuGetVersion)>();
- CLIToolReferences = new List<(LibraryRange, NuGetVersion)>();
}
public PackageSpec PackageSpec { get; }
public List<(NuGetFramework, LibraryRange, NuGetVersion)> Packages { get; }
-
- public List<(LibraryRange, NuGetVersion)> CLIToolReferences { get; }
}
}
}
diff --git a/tools/PinVersions/PinVersions.csproj b/tools/PinVersions/PinVersions.csproj
deleted file mode 100644
index f52efb6b1c..0000000000
--- a/tools/PinVersions/PinVersions.csproj
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
- Exe
- netcoreapp1.1
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/tools/PinVersions/Program.cs b/tools/PinVersions/Program.cs
deleted file mode 100644
index f197fecf5e..0000000000
--- a/tools/PinVersions/Program.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-using System;
-using Microsoft.Extensions.CommandLineUtils;
-using UniverseTools;
-
-namespace PinVersions
-{
- class Program
- {
- static int Main(string[] args)
- {
- var app = new CommandLineApplication();
-
- var pinSourceOption = app.Option("-s|--source",
- "Feed containing packages to pin.",
- CommandOptionType.MultipleValue);
-
- var packageSpecsDirectoryOption = app.Option("--graph-specs-root",
- "Directory containing package specs. (Optional)",
- CommandOptionType.SingleValue);
-
- var repositoryArgument = app.Argument("Repository", "Repository directory");
-
- app.OnExecute(() =>
- {
- if (!pinSourceOption.HasValue())
- {
- Console.Error.WriteLine($"Option {pinSourceOption.Template} must have a value.");
- return 1;
- }
-
- if (string.IsNullOrEmpty(repositoryArgument.Value))
- {
- Console.Error.WriteLine($"Repository argument must be specified.");
- return 1;
- }
-
- var graphSpecProvider = packageSpecsDirectoryOption.HasValue() ?
- new DependencyGraphSpecProvider(packageSpecsDirectoryOption.Value().Trim()) :
- DependencyGraphSpecProvider.Default;
-
- using (graphSpecProvider)
- {
- var pinVersionUtility = new PinVersionUtility(repositoryArgument.Value.Trim(), pinSourceOption.Values, graphSpecProvider);
- pinVersionUtility.Execute();
- }
-
- return 0;
- });
-
- return app.Execute(args);
- }
- }
-}
\ No newline at end of file