From 58de7c4793737ae59c27bd11f8db64e5f548a27c Mon Sep 17 00:00:00 2001 From: David Fowler Date: Sat, 17 Oct 2015 07:20:56 -0700 Subject: [PATCH] Fixed erroneous warning about mismatched dependencies - Fixed lock files parsing issues - Did some cleanup as well --- .../Graph/LockFile.cs | 18 +++++++----------- .../Graph/LockFileReader.cs | 2 +- .../ProjectContext.cs | 7 ------- .../ProjectContextBuilder.cs | 1 - .../ProjectReader.cs | 10 +++++----- .../Resolution/PackageDependencyProvider.cs | 15 --------------- 6 files changed, 13 insertions(+), 40 deletions(-) diff --git a/src/Microsoft.Extensions.ProjectModel/Graph/LockFile.cs b/src/Microsoft.Extensions.ProjectModel/Graph/LockFile.cs index 5007b8b1e..a0a69ba28 100644 --- a/src/Microsoft.Extensions.ProjectModel/Graph/LockFile.cs +++ b/src/Microsoft.Extensions.ProjectModel/Graph/LockFile.cs @@ -88,7 +88,6 @@ namespace Microsoft.Extensions.ProjectModel.Graph { return range.MinVersion.ToString(); } - var sb = new StringBuilder(); sb.Append(">= "); switch (range?.Float?.FloatBehavior) @@ -98,22 +97,19 @@ namespace Microsoft.Extensions.ProjectModel.Graph sb.Append(range.MinVersion); break; case NuGetVersionFloatBehavior.Prerelease: - sb.AppendFormat("{0}-*", range.MinVersion); + // 1.0.* + // Work around nuget bug: https://github.com/NuGet/Home/issues/1598 + // sb.AppendFormat("{0}-*", range.MinVersion); + sb.Append($"{range.MinVersion.Version.Major}.{range.MinVersion.Version.Minor}.{range.MinVersion.Version.Build}-*"); break; case NuGetVersionFloatBehavior.Revision: - sb.AppendFormat("{0}.{1}.{2}.*", - range.MinVersion.Version.Major, - range.MinVersion.Version.Minor, - range.MinVersion.Version.Build); + sb.Append($"{range.MinVersion.Version.Major}.{range.MinVersion.Version.Minor}.{range.MinVersion.Version.Build}.*"); break; case NuGetVersionFloatBehavior.Patch: - sb.AppendFormat("{0}.{1}.*", - range.MinVersion.Version.Major, - range.MinVersion.Version.Minor); + sb.Append($"{range.MinVersion.Version.Major}.{range.MinVersion.Version.Minor}.*"); break; case NuGetVersionFloatBehavior.Minor: - sb.AppendFormat("{0}.{1}.*", - range.MinVersion.Version.Major); + sb.AppendFormat($"{range.MinVersion.Version.Major}.*"); break; case NuGetVersionFloatBehavior.Major: sb.AppendFormat("*"); diff --git a/src/Microsoft.Extensions.ProjectModel/Graph/LockFileReader.cs b/src/Microsoft.Extensions.ProjectModel/Graph/LockFileReader.cs index 5a7fdbebf..022d2d534 100644 --- a/src/Microsoft.Extensions.ProjectModel/Graph/LockFileReader.cs +++ b/src/Microsoft.Extensions.ProjectModel/Graph/LockFileReader.cs @@ -173,7 +173,7 @@ namespace Microsoft.Extensions.ProjectModel.Graph private static ProjectFileDependencyGroup ReadProjectFileDependencyGroup(string property, JsonValue json) { return new ProjectFileDependencyGroup( - NuGetFramework.Parse(property), + string.IsNullOrEmpty(property) ? null : NuGetFramework.Parse(property), ReadArray(json, ReadString)); } diff --git a/src/Microsoft.Extensions.ProjectModel/ProjectContext.cs b/src/Microsoft.Extensions.ProjectModel/ProjectContext.cs index e1da0ec26..7fe33a635 100644 --- a/src/Microsoft.Extensions.ProjectModel/ProjectContext.cs +++ b/src/Microsoft.Extensions.ProjectModel/ProjectContext.cs @@ -5,9 +5,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Runtime.Versioning; using Microsoft.Extensions.ProjectModel.Compilation; -using Microsoft.Extensions.ProjectModel.Graph; using Microsoft.Extensions.ProjectModel.Resolution; using NuGet.Frameworks; @@ -16,7 +14,6 @@ namespace Microsoft.Extensions.ProjectModel // NOTE(anurse): Copied from ApplicationHostContext in DNX. This name seemed more appropriate for this :) public class ProjectContext { - public GlobalSettings GlobalSettings { get; } public ProjectDescription RootProject { get; } @@ -33,8 +30,6 @@ namespace Microsoft.Extensions.ProjectModel public string PackagesDirectory { get; } - public FrameworkReferenceResolver FrameworkResolver { get; } - public LibraryManager LibraryManager { get; } internal ProjectContext( @@ -43,7 +38,6 @@ namespace Microsoft.Extensions.ProjectModel NuGetFramework targetFramework, string runtimeIdentifier, string packagesDirectory, - FrameworkReferenceResolver frameworkResolver, LibraryManager libraryManager) { GlobalSettings = globalSettings; @@ -51,7 +45,6 @@ namespace Microsoft.Extensions.ProjectModel TargetFramework = targetFramework; RuntimeIdentifier = runtimeIdentifier; PackagesDirectory = packagesDirectory; - FrameworkResolver = frameworkResolver; LibraryManager = libraryManager; } diff --git a/src/Microsoft.Extensions.ProjectModel/ProjectContextBuilder.cs b/src/Microsoft.Extensions.ProjectModel/ProjectContextBuilder.cs index af96137f9..60bd42c7d 100644 --- a/src/Microsoft.Extensions.ProjectModel/ProjectContextBuilder.cs +++ b/src/Microsoft.Extensions.ProjectModel/ProjectContextBuilder.cs @@ -100,7 +100,6 @@ namespace Microsoft.Extensions.ProjectModel TargetFramework, target?.RuntimeIdentifier, PackagesDirectory, - frameworkReferenceResolver, libraryManager); } diff --git a/src/Microsoft.Extensions.ProjectModel/ProjectReader.cs b/src/Microsoft.Extensions.ProjectModel/ProjectReader.cs index a16d9ad12..d1939c918 100644 --- a/src/Microsoft.Extensions.ProjectModel/ProjectReader.cs +++ b/src/Microsoft.Extensions.ProjectModel/ProjectReader.cs @@ -54,7 +54,7 @@ namespace Microsoft.Extensions.ProjectModel { try { - var buildVersion = Environment.GetEnvironmentVariable("DNX_BUILD_VERSION"); + var buildVersion = Environment.GetEnvironmentVariable("DOETNET_BUILD_VERSION"); project.Version = SpecifySnapshot(version, buildVersion); } catch (Exception ex) @@ -63,7 +63,7 @@ namespace Microsoft.Extensions.ProjectModel } } - var fileVersion = Environment.GetEnvironmentVariable("DNX_ASSEMBLY_FILE_VERSION"); + var fileVersion = Environment.GetEnvironmentVariable("DOTNET_ASSEMBLY_FILE_VERSION"); if (string.IsNullOrWhiteSpace(fileVersion)) { project.AssemblyFileVersion = project.Version.Version; @@ -94,9 +94,9 @@ namespace Microsoft.Extensions.ProjectModel project.LicenseUrl = rawProject.ValueAsString("licenseUrl"); project.IconUrl = rawProject.ValueAsString("iconUrl"); - project.Authors = rawProject.ValueAsStringArray("authors") ?? new string[] { }; - project.Owners = rawProject.ValueAsStringArray("owners") ?? new string[] { }; - project.Tags = rawProject.ValueAsStringArray("tags") ?? new string[] { }; + project.Authors = rawProject.ValueAsStringArray("authors") ?? Array.Empty(); + project.Owners = rawProject.ValueAsStringArray("owners") ?? Array.Empty(); + project.Tags = rawProject.ValueAsStringArray("tags") ?? Array.Empty(); project.Language = rawProject.ValueAsString("language"); project.ReleaseNotes = rawProject.ValueAsString("releaseNotes"); diff --git a/src/Microsoft.Extensions.ProjectModel/Resolution/PackageDependencyProvider.cs b/src/Microsoft.Extensions.ProjectModel/Resolution/PackageDependencyProvider.cs index 34d1d2726..37766fda9 100644 --- a/src/Microsoft.Extensions.ProjectModel/Resolution/PackageDependencyProvider.cs +++ b/src/Microsoft.Extensions.ProjectModel/Resolution/PackageDependencyProvider.cs @@ -2,9 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Reflection; using Microsoft.Extensions.ProjectModel.Graph; -using Microsoft.Extensions.ProjectModel.Utilities; using NuGet.Packaging; using NuGet.Versioning; @@ -102,18 +100,5 @@ namespace Microsoft.Extensions.ProjectModel.Resolution // TODO(anurse): This should migrate to the NuGet packages directory return Path.Combine(profileDirectory, ".dnx", "packages"); } - - private static IEnumerable GetCacheResolvers() - { - var packageCachePathValue = Environment.GetEnvironmentVariable(EnvironmentNames.PackagesCache); - - if (string.IsNullOrEmpty(packageCachePathValue)) - { - return Enumerable.Empty(); - } - - return packageCachePathValue.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries) - .Select(path => new VersionFolderPathResolver(path)); - } } }