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/RepositoryBuild.targets b/build/RepositoryBuild.targets
index aabf59367f..96ce3623f9 100644
--- a/build/RepositoryBuild.targets
+++ b/build/RepositoryBuild.targets
@@ -22,7 +22,7 @@
BuildInParallel="$(BatchBuilds)"
StopOnFirstFailure="true"
Targets="_BuildRepository"
- Properties="BuildGroup=%(BatchedRepository.BuildGroup)" />
+ Properties="BuildGroup=%(BatchedRepository.BuildGroup);BuildNumber=$(BuildNumber)" />
@@ -78,14 +78,16 @@
-
+
+
+
+
+
-
- $(RepositoryRoot)tools\PinVersions\bin\$(Configuration)\netcoreapp1.1\PinVersions.dll
- $(DotNetPath) $(PinToolBinary) --graph-specs-root "$(_RestoreGraphSpecsDirectory) " -s "$(BuildDir) " "$(BuildRepositoryRoot) "
- $(PinVersionArgs) -s "$(_DependencyPackagesDirectory) "
-
-
-
+
+
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 aeed856381..9df54315a5 100644
--- a/build/repo.targets
+++ b/build/repo.targets
@@ -214,9 +214,4 @@
-
-
-
-
-
diff --git a/build/tasks/BuildGraph/CalculateBuildGraph.cs b/build/tasks/CalculateBuildGraph.cs
similarity index 100%
rename from build/tasks/BuildGraph/CalculateBuildGraph.cs
rename to build/tasks/CalculateBuildGraph.cs
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 f43ff6ef0f..d7ce16d52e 100644
--- a/build/tasks/RepoTasks.csproj
+++ b/build/tasks/RepoTasks.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/build/tasks/RepoTasks.tasks b/build/tasks/RepoTasks.tasks
index b858cdc4aa..6e18f84994 100644
--- a/build/tasks/RepoTasks.tasks
+++ b/build/tasks/RepoTasks.tasks
@@ -4,4 +4,5 @@
-
\ No newline at end of file
+
+
diff --git a/tools/shared/DependencyGraphSpecProvider.cs b/build/tasks/VersionPinning/DependencyGraphSpecProvider.cs
similarity index 87%
rename from tools/shared/DependencyGraphSpecProvider.cs
rename to build/tasks/VersionPinning/DependencyGraphSpecProvider.cs
index 4eb96e1234..eac16e8625 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
{
diff --git a/tools/PinVersions/PinVersionUtility.cs b/build/tasks/VersionPinning/PinVersionUtility.cs
similarity index 87%
rename from tools/PinVersions/PinVersionUtility.cs
rename to build/tasks/VersionPinning/PinVersionUtility.cs
index d7f2fe70aa..c638c40200 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,14 +45,17 @@ namespace PinVersions
}
_provider = provider;
_sourceCacheContext = new SourceCacheContext();
+ _logger = logger;
}
public void Execute()
{
+ _logger.LogMessage(MessageImportance.High, $"Pinning package references for projects in {_repositoryRoot}");
+
var solutionPinMetadata = GetProjectPinVersionMetadata();
foreach (var cliToolReference in solutionPinMetadata.CLIToolReferences)
{
- Console.WriteLine($"Pinning CLI Tool {cliToolReference.Item1.Name}({cliToolReference.Item1.VersionRange} to {cliToolReference.Item2} for all projects in {_repositoryRoot}.");
+ _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)
@@ -53,7 +65,7 @@ namespace PinVersions
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;
}
@@ -66,14 +78,14 @@ namespace PinVersions
if (projectPinMetadata.Packages.Any())
{
- Console.WriteLine($"Pinning package versions for {specProject.FilePath}.");
+ _logger.LogMessage(MessageImportance.Normal, $"Pinning package versions for {specProject.FilePath}.");
}
var pinnedReferences = new XElement("ItemGroup");
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),
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