From 2956446864d668f0821ea89620566c32f15c0d38 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Thu, 7 Apr 2016 14:05:35 -0700 Subject: [PATCH 1/3] update nuget to 1160 --- scripts/dotnet-cli-build/CompileTargets.cs | 4 ++-- scripts/update-dependencies/project.json | 2 +- .../ProjectToolsCommandResolver.cs | 2 +- src/Microsoft.DotNet.Cli.Utils/project.json | 8 ++++---- src/Microsoft.DotNet.ProjectModel/project.json | 4 ++-- src/dotnet/project.json | 18 +++++++++--------- .../project.json | 8 ++++---- tools/RuntimeGraphGenerator/project.json | 4 ++-- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/scripts/dotnet-cli-build/CompileTargets.cs b/scripts/dotnet-cli-build/CompileTargets.cs index e91d82fb9..70279cc76 100644 --- a/scripts/dotnet-cli-build/CompileTargets.cs +++ b/scripts/dotnet-cli-build/CompileTargets.cs @@ -48,7 +48,7 @@ namespace Microsoft.DotNet.Cli.Build return c.Success(); } - // Moving PrepareTargets.RestorePackages after PackagePkgProjects because managed code depends on the + // Moving PrepareTargets.RestorePackages after PackagePkgProjects because managed code depends on the // Microsoft.NETCore.App package that is created during PackagePkgProjects. [Target(nameof(PrepareTargets.Init), nameof(CompileCoreHost), nameof(PackagePkgProjects), nameof(PrepareTargets.RestorePackages), nameof(CompileStage1), nameof(CompileStage2))] public static BuildTargetResult Compile(BuildTargetContext c) @@ -565,7 +565,7 @@ namespace Microsoft.DotNet.Cli.Build // in CompileTargets and the one in the shared library project.json match and are updated in lock step, but long term // we need to be able to look at the project.lock.json file and figure out what version of Microsoft.NETCore.Runtime.CoreCLR // was used, and then select that version. - ExecSilent(Crossgen.GetCrossgenPathForVersion(CompileTargets.CoreCLRVersion), + ExecSilent(Crossgen.GetCrossgenPathForVersion(CoreCLRVersion), "-readytorun", "-in", file, "-out", tempPathName, "-platform_assemblies_paths", pathToAssemblies); File.Delete(file); diff --git a/scripts/update-dependencies/project.json b/scripts/update-dependencies/project.json index caf880730..4d0144085 100644 --- a/scripts/update-dependencies/project.json +++ b/scripts/update-dependencies/project.json @@ -9,7 +9,7 @@ "Microsoft.CSharp": "4.0.1-rc2-24008", "System.Runtime.Serialization.Primitives": "4.1.1-rc2-24008", "Microsoft.DotNet.Cli.Build.Framework": "1.0.0-*", - "NuGet.Versioning": "3.5.0-beta-1130", + "NuGet.Versioning": "3.5.0-beta-1160", "Newtonsoft.Json": "7.0.1", "Octokit": "0.18.0", "Microsoft.Net.Http": "2.2.29" diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectToolsCommandResolver.cs b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectToolsCommandResolver.cs index 49514db98..374d48b51 100644 --- a/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectToolsCommandResolver.cs +++ b/src/Microsoft.DotNet.Cli.Utils/CommandResolution/ProjectToolsCommandResolver.cs @@ -19,7 +19,7 @@ namespace Microsoft.DotNet.Cli.Utils { public class ProjectToolsCommandResolver : ICommandResolver { - private static readonly NuGetFramework s_toolPackageFramework = FrameworkConstants.CommonFrameworks.NetStandardApp15; + private static readonly NuGetFramework s_toolPackageFramework = FrameworkConstants.CommonFrameworks.NetCoreApp10; private static readonly CommandResolutionStrategy s_commandResolutionStrategy = CommandResolutionStrategy.ProjectToolsPackage; diff --git a/src/Microsoft.DotNet.Cli.Utils/project.json b/src/Microsoft.DotNet.Cli.Utils/project.json index c69c99ee6..28c970794 100644 --- a/src/Microsoft.DotNet.Cli.Utils/project.json +++ b/src/Microsoft.DotNet.Cli.Utils/project.json @@ -7,10 +7,10 @@ "dependencies": { "Microsoft.DotNet.ProjectModel": "1.0.0-*", "Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-20459", - "NuGet.Versioning": "3.5.0-beta-1130", - "NuGet.Packaging": "3.5.0-beta-1130", - "NuGet.Frameworks": "3.5.0-beta-1130", - "NuGet.ProjectModel": "3.5.0-beta-1130" + "NuGet.Versioning": "3.5.0-beta-1160", + "NuGet.Packaging": "3.5.0-beta-1160", + "NuGet.Frameworks": "3.5.0-beta-1160", + "NuGet.ProjectModel": "3.5.0-beta-1160" }, "frameworks": { "net451": { diff --git a/src/Microsoft.DotNet.ProjectModel/project.json b/src/Microsoft.DotNet.ProjectModel/project.json index 321004869..787d638ae 100644 --- a/src/Microsoft.DotNet.ProjectModel/project.json +++ b/src/Microsoft.DotNet.ProjectModel/project.json @@ -16,8 +16,8 @@ "version": "1.0.0-rc2-20221" }, "Newtonsoft.Json": "7.0.1", - "NuGet.Packaging": "3.5.0-beta-1130", - "NuGet.RuntimeModel": "3.5.0-beta-1130", + "NuGet.Packaging": "3.5.0-beta-1160", + "NuGet.RuntimeModel": "3.5.0-beta-1160", "System.Reflection.Metadata": "1.3.0-rc2-24008" }, "frameworks": { diff --git a/src/dotnet/project.json b/src/dotnet/project.json index e8baa2eec..e6bd4fb92 100644 --- a/src/dotnet/project.json +++ b/src/dotnet/project.json @@ -17,10 +17,10 @@ ], "dependencies": { "NuGet.Commands": { - "version": "3.5.0-beta-1130", + "version": "3.5.0-beta-1160", "exclude": "compile" }, - "NuGet.CommandLine.XPlat": "3.5.0-beta-1130", + "NuGet.CommandLine.XPlat": "3.5.0-beta-1160", "Newtonsoft.Json": "7.0.1", "System.Text.Encoding.CodePages": "4.0.1-rc2-24008", "System.Diagnostics.FileVersionInfo": "4.0.0-rc2-24008", @@ -55,13 +55,13 @@ } }, "frameworks": { - "netstandard1.5": { - "imports": [ - "dnxcore50", - "netstandardapp1.5", - "portable-net45+win8", - "portable-net45+wp80+win8+wpa81+dnxcore50" - ] + "netcoreapp1.0": { + "imports": [ + "dnxcore50", + "netstandardapp1.5", + "portable-net45+win8", + "portable-net45+wp80+win8+wpa81+dnxcore50" + ] } } } diff --git a/test/Microsoft.DotNet.Cli.Utils.Tests/project.json b/test/Microsoft.DotNet.Cli.Utils.Tests/project.json index 2f693bd56..37cb5ae94 100644 --- a/test/Microsoft.DotNet.Cli.Utils.Tests/project.json +++ b/test/Microsoft.DotNet.Cli.Utils.Tests/project.json @@ -10,10 +10,10 @@ }, "System.Diagnostics.TraceSource": "4.0.0-rc2-24008", "System.Runtime.Serialization.Primitives": "4.1.1-rc2-24008", - "NuGet.Versioning": "3.5.0-beta-1130", - "NuGet.Packaging": "3.5.0-beta-1130", - "NuGet.Frameworks": "3.5.0-beta-1130", - "NuGet.ProjectModel": "3.5.0-beta-1130", + "NuGet.Versioning": "3.5.0-beta-1160", + "NuGet.Packaging": "3.5.0-beta-1160", + "NuGet.Frameworks": "3.5.0-beta-1160", + "NuGet.ProjectModel": "3.5.0-beta-1160", "Microsoft.DotNet.ProjectModel": { "target": "project" }, diff --git a/tools/RuntimeGraphGenerator/project.json b/tools/RuntimeGraphGenerator/project.json index 12f43b9c6..efe35c501 100644 --- a/tools/RuntimeGraphGenerator/project.json +++ b/tools/RuntimeGraphGenerator/project.json @@ -4,8 +4,8 @@ "emitEntryPoint": true }, "dependencies": { - "NuGet.RuntimeModel": "3.5.0-beta-1130", - "NuGet.Versioning": "3.5.0-beta-1130", + "NuGet.RuntimeModel": "3.5.0-beta-1160", + "NuGet.Versioning": "3.5.0-beta-1160", "System.CommandLine": "0.1.0-e160119-1", "System.Runtime.Serialization.Json": "4.0.2-rc2-24008", "Microsoft.DotNet.ProjectModel": "1.0.0-*", From 362397a94500239d0d3707df1eafdaa45d54c716 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Wed, 13 Apr 2016 13:45:35 -0700 Subject: [PATCH 2/3] ensure dotnet-build can see projects under packages --- .../commands/dotnet-build/CompileContext.cs | 38 ++++++++++++------- .../dotnet-build/ProjectDependenciesFacade.cs | 8 ++-- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/dotnet/commands/dotnet-build/CompileContext.cs b/src/dotnet/commands/dotnet-build/CompileContext.cs index 2a9ff80bc..885904a5a 100644 --- a/src/dotnet/commands/dotnet-build/CompileContext.cs +++ b/src/dotnet/commands/dotnet-build/CompileContext.cs @@ -12,6 +12,7 @@ using Microsoft.DotNet.ProjectModel; using Microsoft.DotNet.ProjectModel.Utilities; using Microsoft.DotNet.Tools.Compiler; using Microsoft.Extensions.PlatformAbstractions; +using Microsoft.DotNet.ProjectModel.Compilation; namespace Microsoft.DotNet.Tools.Build { @@ -79,7 +80,7 @@ namespace Microsoft.DotNet.Tools.Build return true; } - foreach (var dependency in Sort(_rootProjectDependencies.ProjectDependenciesWithSources)) + foreach (var dependency in Sort(_rootProjectDependencies)) { var dependencyProjectContext = ProjectContext.Create(dependency.Path, dependency.Framework, new[] { _rootProject.RuntimeIdentifier }); @@ -514,31 +515,40 @@ namespace Microsoft.DotNet.Tools.Build executable.MakeCompilationOutputRunnable(); } - private static ISet Sort(Dictionary projects) + private static IEnumerable Sort(ProjectDependenciesFacade dependencies) { - var outputs = new HashSet(); + var outputs = new List(); - foreach (var pair in projects) + foreach (var pair in dependencies.Dependencies) { - Sort(pair.Value, projects, outputs); + Sort(pair.Value, dependencies, outputs); } - return outputs; + return outputs.Distinct(new ProjectComparer()); } - private static void Sort(ProjectDescription project, Dictionary projects, ISet outputs) + private static void Sort(LibraryExport node, ProjectDependenciesFacade dependencies, IList outputs) { // Sorts projects in dependency order so that we only build them once per chain - foreach (var dependency in project.Dependencies) + ProjectDescription projectDependency; + foreach (var dependency in node.Library.Dependencies) { - ProjectDescription projectDependency; - if (projects.TryGetValue(dependency.Name, out projectDependency)) - { - Sort(projectDependency, projects, outputs); - } + // Sort the children + Sort(dependencies.Dependencies[dependency.Name], dependencies, outputs); } - outputs.Add(project); + // Add this node to the list if it is a project + if (dependencies.ProjectDependenciesWithSources.TryGetValue(node.Library.Identity.Name, out projectDependency)) + { + // Add to the list of projects to build + outputs.Add(projectDependency); + } + } + + private class ProjectComparer : IEqualityComparer + { + public bool Equals(ProjectDescription x, ProjectDescription y) => string.Equals(x.Identity.Name, y.Identity.Name); + public int GetHashCode(ProjectDescription obj) => obj.Identity.Name.GetHashCode(); } public struct CompilerIO diff --git a/src/dotnet/commands/dotnet-build/ProjectDependenciesFacade.cs b/src/dotnet/commands/dotnet-build/ProjectDependenciesFacade.cs index cc5086404..5d8f9372d 100644 --- a/src/dotnet/commands/dotnet-build/ProjectDependenciesFacade.cs +++ b/src/dotnet/commands/dotnet-build/ProjectDependenciesFacade.cs @@ -14,7 +14,7 @@ namespace Microsoft.DotNet.Tools.Build { // projectName -> ProjectDescription public Dictionary ProjectDependenciesWithSources { get; } - public List Dependencies { get; } + public Dictionary Dependencies { get; } public ProjectDependenciesFacade(ProjectContext rootProject, string configValue) { @@ -25,7 +25,7 @@ namespace Microsoft.DotNet.Tools.Build // Build project references foreach (var dependency in Dependencies) { - var projectDependency = dependency.Library as ProjectDescription; + var projectDependency = dependency.Value.Library as ProjectDescription; if (projectDependency != null && projectDependency.Resolved && projectDependency.Project.Files.SourceFiles.Any()) { @@ -35,7 +35,7 @@ namespace Microsoft.DotNet.Tools.Build } // todo make extension of ProjectContext? - private static List GetProjectDependencies(ProjectContext projectContext, string configuration) + private static Dictionary GetProjectDependencies(ProjectContext projectContext, string configuration) { // Create the library exporter var exporter = projectContext.CreateExporter(configuration); @@ -43,7 +43,7 @@ namespace Microsoft.DotNet.Tools.Build // Gather exports for the project var dependencies = exporter.GetDependencies().ToList(); - return dependencies; + return dependencies.ToDictionary(d => d.Library.Identity.Name); } } From 71d5738fff429aef1ecec4d55cd7ae5339f09990 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Wed, 13 Apr 2016 15:59:48 -0700 Subject: [PATCH 3/3] re-restore test projects at their destination since NuGet now stores the relative path to dependent projects in the lock file, projects need to be restored when they are moved --- scripts/dotnet-cli-build/CompileTargets.cs | 2 -- scripts/dotnet-cli-build/PrepareTargets.cs | 2 +- src/dotnet/commands/dotnet-build/CompileContext.cs | 2 +- .../GivenAProjectToolsCommandResolver.cs | 2 +- .../GivenThatWeWantToRunTestsInTheConsole.cs | 7 ++++++- .../GivenThatWeWantToUseDotnetTestE2EInDesignTime.cs | 7 ++++++- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/scripts/dotnet-cli-build/CompileTargets.cs b/scripts/dotnet-cli-build/CompileTargets.cs index 70279cc76..60136fe78 100644 --- a/scripts/dotnet-cli-build/CompileTargets.cs +++ b/scripts/dotnet-cli-build/CompileTargets.cs @@ -230,7 +230,6 @@ namespace Microsoft.DotNet.Cli.Build public static BuildTargetResult CompileStage1(BuildTargetContext c) { CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "src")); - CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "test")); if (Directory.Exists(Dirs.Stage1)) { @@ -258,7 +257,6 @@ namespace Microsoft.DotNet.Cli.Build var configuration = c.BuildContext.Get("Configuration"); CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "src")); - CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "test")); if (Directory.Exists(Dirs.Stage2)) { diff --git a/scripts/dotnet-cli-build/PrepareTargets.cs b/scripts/dotnet-cli-build/PrepareTargets.cs index 56c06a8e6..ce65668ad 100644 --- a/scripts/dotnet-cli-build/PrepareTargets.cs +++ b/scripts/dotnet-cli-build/PrepareTargets.cs @@ -228,7 +228,7 @@ namespace Microsoft.DotNet.Cli.Build { var dotnet = DotNetCli.Stage0; - dotnet.Restore("--verbosity", "verbose", "--disable-parallel", "--infer-runtimes", "--fallbacksource", Dirs.Corehost) + dotnet.Restore("--verbosity", "verbose", "--disable-parallel", "--fallbacksource", Dirs.Corehost) .WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "src")) .Execute() .EnsureSuccessful(); diff --git a/src/dotnet/commands/dotnet-build/CompileContext.cs b/src/dotnet/commands/dotnet-build/CompileContext.cs index 885904a5a..7469d5e9e 100644 --- a/src/dotnet/commands/dotnet-build/CompileContext.cs +++ b/src/dotnet/commands/dotnet-build/CompileContext.cs @@ -547,7 +547,7 @@ namespace Microsoft.DotNet.Tools.Build private class ProjectComparer : IEqualityComparer { - public bool Equals(ProjectDescription x, ProjectDescription y) => string.Equals(x.Identity.Name, y.Identity.Name); + public bool Equals(ProjectDescription x, ProjectDescription y) => string.Equals(x.Identity.Name, y.Identity.Name, StringComparison.Ordinal); public int GetHashCode(ProjectDescription obj) => obj.Identity.Name.GetHashCode(); } diff --git a/test/Microsoft.DotNet.Cli.Utils.Tests/GivenAProjectToolsCommandResolver.cs b/test/Microsoft.DotNet.Cli.Utils.Tests/GivenAProjectToolsCommandResolver.cs index fee3a0417..a8889d522 100644 --- a/test/Microsoft.DotNet.Cli.Utils.Tests/GivenAProjectToolsCommandResolver.cs +++ b/test/Microsoft.DotNet.Cli.Utils.Tests/GivenAProjectToolsCommandResolver.cs @@ -28,7 +28,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests { public class GivenAProjectToolsCommandResolver { - private static readonly NuGetFramework s_toolPackageFramework = FrameworkConstants.CommonFrameworks.NetStandardApp15; + private static readonly NuGetFramework s_toolPackageFramework = FrameworkConstants.CommonFrameworks.NetCoreApp10; private static readonly string s_liveProjectDirectory = Path.Combine(AppContext.BaseDirectory, "TestAssets/TestProjects/AppWithToolDependency"); diff --git a/test/dotnet-test.Tests/GivenThatWeWantToRunTestsInTheConsole.cs b/test/dotnet-test.Tests/GivenThatWeWantToRunTestsInTheConsole.cs index e431ca7ee..be0286aaf 100644 --- a/test/dotnet-test.Tests/GivenThatWeWantToRunTestsInTheConsole.cs +++ b/test/dotnet-test.Tests/GivenThatWeWantToRunTestsInTheConsole.cs @@ -21,7 +21,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests { var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets")); var testInstance = - testAssetManager.CreateTestInstance("ProjectWithTests", identifier: "ConsoleTests").WithLockFiles(); + testAssetManager.CreateTestInstance("ProjectWithTests", identifier: "ConsoleTests"); _projectFilePath = Path.Combine(testInstance.TestRoot, "project.json"); var contexts = ProjectContext.CreateContextForEachFramework( @@ -29,6 +29,11 @@ namespace Microsoft.Dotnet.Tools.Test.Tests null, PlatformServices.Default.Runtime.GetAllCandidateRuntimeIdentifiers()); + // Restore the project again in the destination to resolve projects + // Since the lock file has project relative paths in it, those will be broken + // unless we re-restore + new RestoreCommand() { WorkingDirectory = testInstance.TestRoot }.Execute().Should().Pass(); + _defaultOutputPath = Path.Combine(testInstance.TestRoot, "bin", "Debug", "netcoreapp1.0"); } diff --git a/test/dotnet-test.Tests/GivenThatWeWantToUseDotnetTestE2EInDesignTime.cs b/test/dotnet-test.Tests/GivenThatWeWantToUseDotnetTestE2EInDesignTime.cs index a3e4fd1af..65ed16756 100644 --- a/test/dotnet-test.Tests/GivenThatWeWantToUseDotnetTestE2EInDesignTime.cs +++ b/test/dotnet-test.Tests/GivenThatWeWantToUseDotnetTestE2EInDesignTime.cs @@ -20,7 +20,7 @@ namespace Microsoft.Dotnet.Tools.Test.Tests public GivenThatWeWantToUseDotnetTestE2EInDesignTime() { var testAssetManager = new TestAssetsManager(Path.Combine(RepoRoot, "TestAssets")); - var testInstance = testAssetManager.CreateTestInstance("ProjectWithTests").WithLockFiles(); + var testInstance = testAssetManager.CreateTestInstance("ProjectWithTests"); _projectFilePath = Path.Combine(testInstance.TestRoot, "project.json"); var contexts = ProjectContext.CreateContextForEachFramework( @@ -28,6 +28,11 @@ namespace Microsoft.Dotnet.Tools.Test.Tests null, PlatformServices.Default.Runtime.GetAllCandidateRuntimeIdentifiers()); + // Restore the project again in the destination to resolve projects + // Since the lock file has project relative paths in it, those will be broken + // unless we re-restore + new RestoreCommand() { WorkingDirectory = testInstance.TestRoot }.Execute().Should().Pass(); + _outputPath = Path.Combine(testInstance.TestRoot, "bin", "Debug", "netcoreapp1.0"); var buildCommand = new BuildCommand(_projectFilePath); var result = buildCommand.Execute();