From d672fd865453fd8e632ca12c2bf094469261df0f Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Tue, 27 Feb 2018 12:38:49 -0800 Subject: [PATCH 01/12] Use Array.Empty() instead of new string[0] --- .../Common/CommandLineResponseFile.cs | 4 ++-- .../Projects/VsProjectAdapter.cs | 2 +- .../VsHierarchyUtility.cs | 2 +- .../UnsupportedHost.cs | 4 ++-- .../NuGet.Build.Tasks/GetRestoreSettingsTask.cs | 4 ++-- .../WarnForInvalidProjectsTask.cs | 5 +++-- .../NuGet.Common/MsBuildStringUtility.cs | 4 ++-- .../NuGet.Packaging/TopologicalSortUtility.cs | 2 +- .../NuGet.ProjectModel/JsonPackageSpecReader.cs | 4 ++-- src/NuGet.Core/NuGet.ProjectModel/PackageSpec.cs | 6 +++--- .../NuGet.Protocol/LegacyFeed/V2FeedPackageInfo.cs | 4 ++-- .../NuGet.Versioning/SemanticVersionFactory.cs | 2 +- .../NuGet.Build.Tasks.Pack.Test/PackTaskTests.cs | 14 +++++++------- .../GetRestoreSettingTaskTests.cs | 2 +- .../InstallationCompatibilityTests.cs | 2 +- .../SigningTests/AttributeUtilityTests.cs | 2 +- .../SigningTests/NuGetPackageOwnersTests.cs | 2 +- .../SigningTests/SigningUtilityTests.cs | 2 +- .../NuGet.ProjectModel.Test/LockFileFormatTests.cs | 12 ++++++------ .../NuGet.Versioning.Test/NuGetVersionTest.cs | 2 +- .../FileExistsFactAttribute.cs | 2 +- .../FileExistsInNuGetRoamingFactAttribute.cs | 2 +- .../FileExistsInNuGetRoamingTheoryAttribute.cs | 2 +- .../FileExistsTheoryAttribute.cs | 2 +- .../PlatformFactAttribute.cs | 4 ++-- .../PlatformTheoryAttribute.cs | 4 ++-- test/TestUtilities/Test.Utility/TestPackages.cs | 2 +- 27 files changed, 50 insertions(+), 49 deletions(-) diff --git a/src/NuGet.Clients/NuGet.CommandLine/Common/CommandLineResponseFile.cs b/src/NuGet.Clients/NuGet.CommandLine/Common/CommandLineResponseFile.cs index a13bd67c15c..d0b02ac85fc 100644 --- a/src/NuGet.Clients/NuGet.CommandLine/Common/CommandLineResponseFile.cs +++ b/src/NuGet.Clients/NuGet.CommandLine/Common/CommandLineResponseFile.cs @@ -126,13 +126,13 @@ private static string[] SplitArgs(string unsplitArguments) { if (string.IsNullOrWhiteSpace(unsplitArguments)) { - return new string[0]; + return Array.Empty(); } var ptrToSplitArgs = CommandLineToArgvW(unsplitArguments, out int numberOfArgs); if (ptrToSplitArgs == IntPtr.Zero) { - return new string[0]; + return Array.Empty(); } try diff --git a/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/VsProjectAdapter.cs b/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/VsProjectAdapter.cs index 94775ea035e..2c6b8195367 100644 --- a/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/VsProjectAdapter.cs +++ b/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/VsProjectAdapter.cs @@ -278,7 +278,7 @@ public async Task GetProjectTypeGuidsAsync() return new string[] { _projectTypeGuid }; } - return new string[0]; + return Array.Empty(); } } diff --git a/src/NuGet.Clients/NuGet.VisualStudio.Common/VsHierarchyUtility.cs b/src/NuGet.Clients/NuGet.VisualStudio.Common/VsHierarchyUtility.cs index ad57979f2c0..c1333351c09 100644 --- a/src/NuGet.Clients/NuGet.VisualStudio.Common/VsHierarchyUtility.cs +++ b/src/NuGet.Clients/NuGet.VisualStudio.Common/VsHierarchyUtility.cs @@ -104,7 +104,7 @@ public static string[] GetProjectTypeGuids(IVsHierarchy hierarchy, string defaul return new[] { defaultType }; } - return new string[0]; + return Array.Empty(); } /// diff --git a/src/NuGet.Clients/NuGetConsole.Host.PowerShell/UnsupportedHost.cs b/src/NuGet.Clients/NuGetConsole.Host.PowerShell/UnsupportedHost.cs index 5ef3dc627c4..a23200f1f45 100644 --- a/src/NuGet.Clients/NuGetConsole.Host.PowerShell/UnsupportedHost.cs +++ b/src/NuGet.Clients/NuGetConsole.Host.PowerShell/UnsupportedHost.cs @@ -46,7 +46,7 @@ public string ActivePackageSource public string[] GetPackageSources() { - return new string[0]; + return Array.Empty(); } public string DefaultProject @@ -60,7 +60,7 @@ public void SetDefaultProjectIndex(int index) public string[] GetAvailableProjects() { - return new string[0]; + return Array.Empty(); } public void SetDefaultRunspace() diff --git a/src/NuGet.Core/NuGet.Build.Tasks/GetRestoreSettingsTask.cs b/src/NuGet.Core/NuGet.Build.Tasks/GetRestoreSettingsTask.cs index 0601f9f7170..1d3788bbfa0 100644 --- a/src/NuGet.Core/NuGet.Build.Tasks/GetRestoreSettingsTask.cs +++ b/src/NuGet.Core/NuGet.Build.Tasks/GetRestoreSettingsTask.cs @@ -131,7 +131,7 @@ public override bool Execute() // Sources var currentSources = RestoreSettingsUtils.GetValue( () => RestoreSourcesOverride?.Select(MSBuildRestoreUtility.FixSourcePath).Select(e => GetGlobalAbsolutePath(e)).ToArray(), - () => MSBuildRestoreUtility.ContainsClearKeyword(RestoreSources) ? new string[0] : null, + () => MSBuildRestoreUtility.ContainsClearKeyword(RestoreSources) ? Array.Empty() : null, () => RestoreSources?.Select(MSBuildRestoreUtility.FixSourcePath).Select(e => UriUtility.GetAbsolutePathFromFile(ProjectUniqueName, e)).ToArray(), () => (new PackageSourceProvider(settings)).LoadPackageSources().Where(e => e.IsEnabled).Select(e => e.Source).ToArray()); @@ -148,7 +148,7 @@ public override bool Execute() // Fallback folders var currentFallbackFolders = RestoreSettingsUtils.GetValue( () => RestoreFallbackFoldersOverride?.Select(e => GetGlobalAbsolutePath(e)).ToArray(), - () => MSBuildRestoreUtility.ContainsClearKeyword(RestoreFallbackFolders) ? new string[0] : null, + () => MSBuildRestoreUtility.ContainsClearKeyword(RestoreFallbackFolders) ? Array.Empty() : null, () => RestoreFallbackFolders?.Select(e => UriUtility.GetAbsolutePathFromFile(ProjectUniqueName, e)).ToArray(), () => SettingsUtility.GetFallbackPackageFolders(settings).ToArray()); diff --git a/src/NuGet.Core/NuGet.Build.Tasks/WarnForInvalidProjectsTask.cs b/src/NuGet.Core/NuGet.Build.Tasks/WarnForInvalidProjectsTask.cs index be9ac2a92b7..6cb1ed5c68c 100644 --- a/src/NuGet.Core/NuGet.Build.Tasks/WarnForInvalidProjectsTask.cs +++ b/src/NuGet.Core/NuGet.Build.Tasks/WarnForInvalidProjectsTask.cs @@ -1,6 +1,7 @@ // 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.Utilities; @@ -28,8 +29,8 @@ public override bool Execute() var log = new MSBuildLogger(Log); // item -> string - var all = AllProjects?.Select(e => e.ItemSpec).ToArray() ?? new string[0]; - var valid = ValidProjects?.Select(e => e.ItemSpec).ToArray() ?? new string[0]; + var all = AllProjects?.Select(e => e.ItemSpec).ToArray() ?? Array.Empty(); + var valid = ValidProjects?.Select(e => e.ItemSpec).ToArray() ?? Array.Empty(); // log inputs BuildTasksUtility.LogInputParam(log, nameof(AllProjects), all); diff --git a/src/NuGet.Core/NuGet.Common/MsBuildStringUtility.cs b/src/NuGet.Core/NuGet.Common/MsBuildStringUtility.cs index 49dae7d2f91..8a9c3eaf224 100644 --- a/src/NuGet.Core/NuGet.Common/MsBuildStringUtility.cs +++ b/src/NuGet.Core/NuGet.Common/MsBuildStringUtility.cs @@ -34,7 +34,7 @@ public static string[] Split(string s, params char[] chars) .ToArray(); } - return new string[0]; + return Array.Empty(); } /// @@ -59,7 +59,7 @@ public static string[] TrimAndExcludeNullOrEmpty(string[] strings) { if (strings == null) { - return new string[0]; + return Array.Empty(); } return strings diff --git a/src/NuGet.Core/NuGet.Packaging/TopologicalSortUtility.cs b/src/NuGet.Core/NuGet.Packaging/TopologicalSortUtility.cs index 8f00c35376c..b0c8cd4cb29 100644 --- a/src/NuGet.Core/NuGet.Packaging/TopologicalSortUtility.cs +++ b/src/NuGet.Core/NuGet.Packaging/TopologicalSortUtility.cs @@ -141,7 +141,7 @@ private static void CalculateRelationships(ItemDependencyInfo[] packages, Dictio { foreach (var package in packages) { - var dependencies = package.DependencyIds ?? new string[0]; + var dependencies = package.DependencyIds ?? Array.Empty(); foreach (var id in dependencies) { diff --git a/src/NuGet.Core/NuGet.ProjectModel/JsonPackageSpecReader.cs b/src/NuGet.Core/NuGet.ProjectModel/JsonPackageSpecReader.cs index 0d6762818f9..366e74d15ae 100644 --- a/src/NuGet.Core/NuGet.ProjectModel/JsonPackageSpecReader.cs +++ b/src/NuGet.Core/NuGet.ProjectModel/JsonPackageSpecReader.cs @@ -346,8 +346,8 @@ private static PackOptions GetPackOptions(PackageSpec packageSpec, JObject rawPa } var owners = rawPackOptions["owners"]; var tags = rawPackOptions["tags"]; - packageSpec.Owners = owners == null ? new string[0] { } : owners.ValueAsArray(); - packageSpec.Tags = tags == null ? new string[0] { } : tags.ValueAsArray(); + packageSpec.Owners = owners == null ? Array.Empty() : owners.ValueAsArray(); + packageSpec.Tags = tags == null ? Array.Empty() : tags.ValueAsArray(); packageSpec.ProjectUrl = rawPackOptions.GetValue("projectUrl"); packageSpec.IconUrl = rawPackOptions.GetValue("iconUrl"); packageSpec.Summary = rawPackOptions.GetValue("summary"); diff --git a/src/NuGet.Core/NuGet.ProjectModel/PackageSpec.cs b/src/NuGet.Core/NuGet.ProjectModel/PackageSpec.cs index d60f3aff2b6..04f4d915c71 100644 --- a/src/NuGet.Core/NuGet.ProjectModel/PackageSpec.cs +++ b/src/NuGet.Core/NuGet.ProjectModel/PackageSpec.cs @@ -59,9 +59,9 @@ public NuGetVersion Version public string ReleaseNotes { get; set; } - public string[] Authors { get; set; } = new string[0]; + public string[] Authors { get; set; } = Array.Empty(); - public string[] Owners { get; set; } = new string[0]; + public string[] Owners { get; set; } = Array.Empty(); public string ProjectUrl { get; set; } @@ -77,7 +77,7 @@ public NuGetVersion Version public BuildOptions BuildOptions { get; set; } - public string[] Tags { get; set; } = new string[0]; + public string[] Tags { get; set; } = Array.Empty(); public IList ContentFiles { get; set; } = new List(); diff --git a/src/NuGet.Core/NuGet.Protocol/LegacyFeed/V2FeedPackageInfo.cs b/src/NuGet.Core/NuGet.Protocol/LegacyFeed/V2FeedPackageInfo.cs index 0849dd62f64..46c286ddaa4 100644 --- a/src/NuGet.Core/NuGet.Protocol/LegacyFeed/V2FeedPackageInfo.cs +++ b/src/NuGet.Core/NuGet.Protocol/LegacyFeed/V2FeedPackageInfo.cs @@ -48,8 +48,8 @@ public V2FeedPackageInfo(PackageIdentity identity, string title, string summary, { _summary = summary; _description = description; - _authors = authors == null ? new string[0] : authors.ToArray(); - _owners = owners == null ? new string[0] : owners.ToArray(); + _authors = authors == null ? Array.Empty() : authors.ToArray(); + _owners = owners == null ? Array.Empty() : owners.ToArray(); _iconUrl = iconUrl; _licenseUrl = licenseUrl; _projectUrl = projectUrl; diff --git a/src/NuGet.Core/NuGet.Versioning/SemanticVersionFactory.cs b/src/NuGet.Core/NuGet.Versioning/SemanticVersionFactory.cs index 3e57a3be045..8285ba4f03c 100644 --- a/src/NuGet.Core/NuGet.Versioning/SemanticVersionFactory.cs +++ b/src/NuGet.Core/NuGet.Versioning/SemanticVersionFactory.cs @@ -9,7 +9,7 @@ namespace NuGet.Versioning public partial class SemanticVersion { // Reusable set of empty release labels - internal static readonly string[] EmptyReleaseLabels = new string[0]; + internal static readonly string[] EmptyReleaseLabels = Array.Empty(); /// /// Parses a SemVer string using strict SemVer rules. diff --git a/test/NuGet.Core.Tests/NuGet.Build.Tasks.Pack.Test/PackTaskTests.cs b/test/NuGet.Core.Tests/NuGet.Build.Tasks.Pack.Test/PackTaskTests.cs index 18f3be6c95e..c503e0f2e86 100644 --- a/test/NuGet.Core.Tests/NuGet.Build.Tasks.Pack.Test/PackTaskTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Build.Tasks.Pack.Test/PackTaskTests.cs @@ -317,9 +317,9 @@ public void PackTask_MapsAllProperties() { AssemblyName = "AssemblyName", FrameworkAssemblyReferences = new ITaskItem[0], - Authors = new string[0], - AllowedOutputExtensionsInPackageBuildOutputFolder = new string[0], - AllowedOutputExtensionsInSymbolsPackageBuildOutputFolder = new string[0], + Authors = Array.Empty(), + AllowedOutputExtensionsInPackageBuildOutputFolder = Array.Empty(), + AllowedOutputExtensionsInSymbolsPackageBuildOutputFolder = Array.Empty(), BuildOutputFolder = "BuildOutputFolder", ContentTargetFolders = new string[] { "ContentTargetFolders" } , ContinuePackingAfterGeneratingNuspec = true, @@ -335,13 +335,13 @@ public void PackTask_MapsAllProperties() MinClientVersion = "MinClientVersion", NoPackageAnalysis = true, NuspecOutputPath = "NuspecOutputPath", - NuspecProperties = new string[0], + NuspecProperties = Array.Empty(), PackItem = null, // This is asserted by other tests. It does not serialize well. PackageFiles = new ITaskItem[0], PackageFilesToExclude = new ITaskItem[0], PackageId = "PackageId", PackageOutputPath = "PackageOutputPath", - PackageTypes = new string[0], + PackageTypes = Array.Empty(), PackageVersion = "PackageVersion", ProjectReferencesWithVersions = new ITaskItem[0], ProjectUrl = "ProjectUrl", @@ -353,8 +353,8 @@ public void PackTask_MapsAllProperties() RequireLicenseAcceptance = true, Serviceable = true, SourceFiles = new ITaskItem[0], - Tags = new string[0], - TargetFrameworks = new string[0], + Tags = Array.Empty(), + TargetFrameworks = Array.Empty(), BuildOutputInPackage = new ITaskItem[0], TargetPathsToSymbols = new ITaskItem[0] }; diff --git a/test/NuGet.Core.Tests/NuGet.Build.Tasks.Test/GetRestoreSettingTaskTests.cs b/test/NuGet.Core.Tests/NuGet.Build.Tasks.Test/GetRestoreSettingTaskTests.cs index b9d05799854..1f00d5d290b 100644 --- a/test/NuGet.Core.Tests/NuGet.Build.Tasks.Test/GetRestoreSettingTaskTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Build.Tasks.Test/GetRestoreSettingTaskTests.cs @@ -42,7 +42,7 @@ public void GetRestoreSettingsTask_GetValueGetLastValue() RestoreSettingsUtils.GetValue( () => null, () => null, - () => new string[0]).ShouldBeEquivalentTo(new string[0]); + () => Array.Empty()).ShouldBeEquivalentTo(Array.Empty()); } [Fact] diff --git a/test/NuGet.Core.Tests/NuGet.PackageManagement.Test/InstallationCompatibilityTests.cs b/test/NuGet.Core.Tests/NuGet.PackageManagement.Test/InstallationCompatibilityTests.cs index cb2c27e30ab..69fadce5b51 100644 --- a/test/NuGet.Core.Tests/NuGet.PackageManagement.Test/InstallationCompatibilityTests.cs +++ b/test/NuGet.Core.Tests/NuGet.PackageManagement.Test/InstallationCompatibilityTests.cs @@ -361,7 +361,7 @@ public TestContext(string userPackageFolder = null) .Returns(userPackageFolder); NuGetPathContext .Setup(x => x.FallbackPackageFolders) - .Returns(new string[0]); + .Returns(Array.Empty()); NuspecReader .Setup(p => p.GetIdentity()) diff --git a/test/NuGet.Core.Tests/NuGet.Packaging.Test/SigningTests/AttributeUtilityTests.cs b/test/NuGet.Core.Tests/NuGet.Packaging.Test/SigningTests/AttributeUtilityTests.cs index 45f069113d7..23310c525f9 100644 --- a/test/NuGet.Core.Tests/NuGet.Packaging.Test/SigningTests/AttributeUtilityTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Packaging.Test/SigningTests/AttributeUtilityTests.cs @@ -566,7 +566,7 @@ public void CreateNuGetPackageOwners_WhenPackageOwnersNull_Throws() public void CreateNuGetPackageOwners_WhenPackageOwnersEmpty_Throws() { var exception = Assert.Throws( - () => AttributeUtility.CreateNuGetPackageOwners(new string[0])); + () => AttributeUtility.CreateNuGetPackageOwners(Array.Empty())); Assert.Equal("packageOwners", exception.ParamName); Assert.StartsWith("The argument cannot be null or empty.", exception.Message); diff --git a/test/NuGet.Core.Tests/NuGet.Packaging.Test/SigningTests/NuGetPackageOwnersTests.cs b/test/NuGet.Core.Tests/NuGet.Packaging.Test/SigningTests/NuGetPackageOwnersTests.cs index b49d83a93e7..f80ac20e2a2 100644 --- a/test/NuGet.Core.Tests/NuGet.Packaging.Test/SigningTests/NuGetPackageOwnersTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Packaging.Test/SigningTests/NuGetPackageOwnersTests.cs @@ -25,7 +25,7 @@ public void Constructor_WhenPackageOwnersNull_Throws() public void Constructor_WhenPackageOwnersEmpty_Throws() { var exception = Assert.Throws( - () => new NuGetPackageOwners(new string[0])); + () => new NuGetPackageOwners(Array.Empty())); Assert.Equal("packageOwners", exception.ParamName); Assert.StartsWith("The argument cannot be null or empty.", exception.Message); diff --git a/test/NuGet.Core.Tests/NuGet.Packaging.Test/SigningTests/SigningUtilityTests.cs b/test/NuGet.Core.Tests/NuGet.Packaging.Test/SigningTests/SigningUtilityTests.cs index 6de36f93214..c6200d6587d 100644 --- a/test/NuGet.Core.Tests/NuGet.Packaging.Test/SigningTests/SigningUtilityTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Packaging.Test/SigningTests/SigningUtilityTests.cs @@ -267,7 +267,7 @@ public void CreateSignedAttributes_RepositorySignPackageRequest_WhenPackageOwner public void CreateSignedAttributes_RepositorySignPackageRequest_WhenPackageOwnersEmpty_ReturnsAttributes() { var v3ServiceIndexUrl = new Uri("https://test.test", UriKind.Absolute); - var packageOwners = new string[0]; + var packageOwners = Array.Empty(); using (var certificate = _fixture.GetDefaultCertificate()) using (var request = CreateRequestRepository(certificate, v3ServiceIndexUrl, packageOwners)) diff --git a/test/NuGet.Core.Tests/NuGet.ProjectModel.Test/LockFileFormatTests.cs b/test/NuGet.Core.Tests/NuGet.ProjectModel.Test/LockFileFormatTests.cs index c16f81a1a0c..331dbf82aba 100644 --- a/test/NuGet.Core.Tests/NuGet.ProjectModel.Test/LockFileFormatTests.cs +++ b/test/NuGet.Core.Tests/NuGet.ProjectModel.Test/LockFileFormatTests.cs @@ -317,7 +317,7 @@ public void LockFileFormat_WritesLockFile() lockFile.ProjectFileDependencyGroups.Add( new ProjectFileDependencyGroup("", new string[] { "System.Runtime [4.0.10-beta-*, )" })); lockFile.ProjectFileDependencyGroups.Add( - new ProjectFileDependencyGroup(FrameworkConstants.CommonFrameworks.DotNet.DotNetFrameworkName, new string[0])); + new ProjectFileDependencyGroup(FrameworkConstants.CommonFrameworks.DotNet.DotNetFrameworkName, Array.Empty())); // Act var lockFileFormat = new LockFileFormat(); @@ -547,7 +547,7 @@ public void LockFileFormat_WritesMinimalErrorMessage() lockFile.ProjectFileDependencyGroups.Add( new ProjectFileDependencyGroup("", new string[] { "System.Runtime [4.0.10-beta-*, )" })); lockFile.ProjectFileDependencyGroups.Add( - new ProjectFileDependencyGroup(FrameworkConstants.CommonFrameworks.DotNet.DotNetFrameworkName, new string[0])); + new ProjectFileDependencyGroup(FrameworkConstants.CommonFrameworks.DotNet.DotNetFrameworkName, Array.Empty())); lockFile.LogMessages = new List { @@ -658,7 +658,7 @@ public void LockFileFormat_WritesMultipleErrorMessages() lockFile.ProjectFileDependencyGroups.Add( new ProjectFileDependencyGroup("", new string[] { "System.Runtime [4.0.10-beta-*, )" })); lockFile.ProjectFileDependencyGroups.Add( - new ProjectFileDependencyGroup(FrameworkConstants.CommonFrameworks.DotNet.DotNetFrameworkName, new string[0])); + new ProjectFileDependencyGroup(FrameworkConstants.CommonFrameworks.DotNet.DotNetFrameworkName, Array.Empty())); lockFile.LogMessages = new List { @@ -774,7 +774,7 @@ public void LockFileFormat_WritesFullErrorMessage() lockFile.ProjectFileDependencyGroups.Add( new ProjectFileDependencyGroup("", new string[] { "System.Runtime [4.0.10-beta-*, )" })); lockFile.ProjectFileDependencyGroups.Add( - new ProjectFileDependencyGroup(FrameworkConstants.CommonFrameworks.DotNet.DotNetFrameworkName, new string[0])); + new ProjectFileDependencyGroup(FrameworkConstants.CommonFrameworks.DotNet.DotNetFrameworkName, Array.Empty())); lockFile.LogMessages = new List { @@ -893,7 +893,7 @@ public void LockFileFormat_WritesErrorMessageWithFilePathSameAsProjectPath() lockFile.ProjectFileDependencyGroups.Add( new ProjectFileDependencyGroup("", new string[] { "System.Runtime [4.0.10-beta-*, )" })); lockFile.ProjectFileDependencyGroups.Add( - new ProjectFileDependencyGroup(FrameworkConstants.CommonFrameworks.DotNet.DotNetFrameworkName, new string[0])); + new ProjectFileDependencyGroup(FrameworkConstants.CommonFrameworks.DotNet.DotNetFrameworkName, Array.Empty())); lockFile.PackageSpec = new PackageSpec(new List()) { RestoreMetadata = new ProjectRestoreMetadata() @@ -1006,7 +1006,7 @@ public void LockFileFormat_WritesMinimalWarningMessageWithWarningLevel() lockFile.ProjectFileDependencyGroups.Add( new ProjectFileDependencyGroup("", new string[] { "System.Runtime [4.0.10-beta-*, )" })); lockFile.ProjectFileDependencyGroups.Add( - new ProjectFileDependencyGroup(FrameworkConstants.CommonFrameworks.DotNet.DotNetFrameworkName, new string[0])); + new ProjectFileDependencyGroup(FrameworkConstants.CommonFrameworks.DotNet.DotNetFrameworkName, Array.Empty())); lockFile.LogMessages = new List { diff --git a/test/NuGet.Core.Tests/NuGet.Versioning.Test/NuGetVersionTest.cs b/test/NuGet.Core.Tests/NuGet.Versioning.Test/NuGetVersionTest.cs index 1543b37b87c..1222e936472 100644 --- a/test/NuGet.Core.Tests/NuGet.Versioning.Test/NuGetVersionTest.cs +++ b/test/NuGet.Core.Tests/NuGet.Versioning.Test/NuGetVersionTest.cs @@ -26,7 +26,7 @@ public void NuGetVersionConstructors() versions.Add(new NuGetVersion(4, 3, 0, string.Empty)); versions.Add(new NuGetVersion(4, 3, 0, null)); versions.Add(new NuGetVersion(4, 3, 0, 0)); - versions.Add(new NuGetVersion(new Version(4, 3, 0), new string[0], string.Empty, "4.3")); + versions.Add(new NuGetVersion(new Version(4, 3, 0), Array.Empty(), string.Empty, "4.3")); versions.Add(new SemanticVersion(4, 3, 0)); versions.Add(new SemanticVersion(4, 3, 0, string.Empty)); diff --git a/test/TestUtilities/Test.Utility/PlatformXunitAttributes/FileExistsFactAttribute.cs b/test/TestUtilities/Test.Utility/PlatformXunitAttributes/FileExistsFactAttribute.cs index e95fcceaf95..530794dedbf 100644 --- a/test/TestUtilities/Test.Utility/PlatformXunitAttributes/FileExistsFactAttribute.cs +++ b/test/TestUtilities/Test.Utility/PlatformXunitAttributes/FileExistsFactAttribute.cs @@ -55,7 +55,7 @@ public FileExistsFactAttribute(params string[] paths) private string[] GetPaths() { - var paths = new HashSet(Paths ?? new string[0], StringComparer.OrdinalIgnoreCase) + var paths = new HashSet(Paths ?? Array.Empty(), StringComparer.OrdinalIgnoreCase) { Path }; diff --git a/test/TestUtilities/Test.Utility/PlatformXunitAttributes/FileExistsInNuGetRoamingFactAttribute.cs b/test/TestUtilities/Test.Utility/PlatformXunitAttributes/FileExistsInNuGetRoamingFactAttribute.cs index fa35b64eb3b..d2a73497f72 100644 --- a/test/TestUtilities/Test.Utility/PlatformXunitAttributes/FileExistsInNuGetRoamingFactAttribute.cs +++ b/test/TestUtilities/Test.Utility/PlatformXunitAttributes/FileExistsInNuGetRoamingFactAttribute.cs @@ -58,7 +58,7 @@ public FileExistsInNuGetRoamingFactAttribute(params string[] paths) private string[] GetPaths() { - var paths = new HashSet(Paths ?? new string[0], StringComparer.OrdinalIgnoreCase) + var paths = new HashSet(Paths ?? Array.Empty(), StringComparer.OrdinalIgnoreCase) { Path }; diff --git a/test/TestUtilities/Test.Utility/PlatformXunitAttributes/FileExistsInNuGetRoamingTheoryAttribute.cs b/test/TestUtilities/Test.Utility/PlatformXunitAttributes/FileExistsInNuGetRoamingTheoryAttribute.cs index dbcca28862d..88679ff7c86 100644 --- a/test/TestUtilities/Test.Utility/PlatformXunitAttributes/FileExistsInNuGetRoamingTheoryAttribute.cs +++ b/test/TestUtilities/Test.Utility/PlatformXunitAttributes/FileExistsInNuGetRoamingTheoryAttribute.cs @@ -58,7 +58,7 @@ public FileExistsInNuGetRoamingTheoryAttribute(params string[] paths) private string[] GetPaths() { - var paths = new HashSet(Paths ?? new string[0], StringComparer.OrdinalIgnoreCase) + var paths = new HashSet(Paths ?? Array.Empty(), StringComparer.OrdinalIgnoreCase) { Path }; diff --git a/test/TestUtilities/Test.Utility/PlatformXunitAttributes/FileExistsTheoryAttribute.cs b/test/TestUtilities/Test.Utility/PlatformXunitAttributes/FileExistsTheoryAttribute.cs index 10a85ae490e..ea671b375ba 100644 --- a/test/TestUtilities/Test.Utility/PlatformXunitAttributes/FileExistsTheoryAttribute.cs +++ b/test/TestUtilities/Test.Utility/PlatformXunitAttributes/FileExistsTheoryAttribute.cs @@ -55,7 +55,7 @@ public FileExistsTheoryAttribute(params string[] paths) private string[] GetPaths() { - var paths = new HashSet(Paths ?? new string[0], StringComparer.OrdinalIgnoreCase) + var paths = new HashSet(Paths ?? Array.Empty(), StringComparer.OrdinalIgnoreCase) { Path }; diff --git a/test/TestUtilities/Test.Utility/PlatformXunitAttributes/PlatformFactAttribute.cs b/test/TestUtilities/Test.Utility/PlatformXunitAttributes/PlatformFactAttribute.cs index b99744cddf8..fa618c66ba7 100644 --- a/test/TestUtilities/Test.Utility/PlatformXunitAttributes/PlatformFactAttribute.cs +++ b/test/TestUtilities/Test.Utility/PlatformXunitAttributes/PlatformFactAttribute.cs @@ -68,12 +68,12 @@ public PlatformFactAttribute(params string[] platforms) private string[] GetAllPlatforms() { - var platforms = new HashSet(Platforms ?? new string[0], StringComparer.OrdinalIgnoreCase) + var platforms = new HashSet(Platforms ?? Array.Empty(), StringComparer.OrdinalIgnoreCase) { Platform }; - var skipPlatforms = new HashSet(SkipPlatforms ?? new string[0], StringComparer.OrdinalIgnoreCase) + var skipPlatforms = new HashSet(SkipPlatforms ?? Array.Empty(), StringComparer.OrdinalIgnoreCase) { SkipPlatform }; diff --git a/test/TestUtilities/Test.Utility/PlatformXunitAttributes/PlatformTheoryAttribute.cs b/test/TestUtilities/Test.Utility/PlatformXunitAttributes/PlatformTheoryAttribute.cs index 281afa059cb..b3b2f122320 100644 --- a/test/TestUtilities/Test.Utility/PlatformXunitAttributes/PlatformTheoryAttribute.cs +++ b/test/TestUtilities/Test.Utility/PlatformXunitAttributes/PlatformTheoryAttribute.cs @@ -68,12 +68,12 @@ public PlatformTheoryAttribute(params string[] platforms) private string[] GetAllPlatforms() { - var platforms = new HashSet(Platforms ?? new string[0], StringComparer.OrdinalIgnoreCase) + var platforms = new HashSet(Platforms ?? Array.Empty(), StringComparer.OrdinalIgnoreCase) { Platform }; - var skipPlatforms = new HashSet(SkipPlatforms ?? new string[0], StringComparer.OrdinalIgnoreCase) + var skipPlatforms = new HashSet(SkipPlatforms ?? Array.Empty(), StringComparer.OrdinalIgnoreCase) { SkipPlatform }; diff --git a/test/TestUtilities/Test.Utility/TestPackages.cs b/test/TestUtilities/Test.Utility/TestPackages.cs index ef2a106b0a6..2f5c947b5bd 100644 --- a/test/TestUtilities/Test.Utility/TestPackages.cs +++ b/test/TestUtilities/Test.Utility/TestPackages.cs @@ -238,7 +238,7 @@ public static FileInfo GetLegacySolutionLevelPackage(string path, string package public static FileInfo GetInvalidPackage(string path, string packageId, string packageVersion) { - return GeneratePackage(path, packageId, packageVersion, new string[0]); + return GeneratePackage(path, packageId, packageVersion, Array.Empty()); } public static FileInfo GetEmptyPackageWithDependencies(string path, string packageId, string packageVersion) From 860754924cfc0e189d96f66b5a18ad21411add34 Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Tue, 27 Feb 2018 15:22:04 -0800 Subject: [PATCH 02/12] Use MSBuildProjectExtensionsPath for RestoreOutputPath, and error if they don't match --- .../NuGet.Build.Tasks.Pack.targets | 2 +- .../ErrorForMismatchRestoreOutputPathTask.cs | 31 +++++++++++++++++++ .../NuGet.Build.Tasks/NuGet.targets | 9 +++++- .../Utility/MSBuildRestoreUtility.cs | 9 ++++++ .../NuGet.Commands/Strings.Designer.cs | 9 ++++++ src/NuGet.Core/NuGet.Commands/Strings.resx | 3 ++ .../NuGet.Common/Errors/NuGetLogCode.cs | 7 ++++- 7 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 src/NuGet.Core/NuGet.Build.Tasks/ErrorForMismatchRestoreOutputPathTask.cs diff --git a/src/NuGet.Core/NuGet.Build.Tasks.Pack/NuGet.Build.Tasks.Pack.targets b/src/NuGet.Core/NuGet.Build.Tasks.Pack/NuGet.Build.Tasks.Pack.targets index ddb19636eb6..b6414d1eebb 100644 --- a/src/NuGet.Core/NuGet.Build.Tasks.Pack/NuGet.Build.Tasks.Pack.targets +++ b/src/NuGet.Core/NuGet.Build.Tasks.Pack/NuGet.Build.Tasks.Pack.targets @@ -148,7 +148,7 @@ Copyright (c) .NET Foundation. All rights reserved. $(OutputPath) - $(BaseIntermediateOutputPath) + $(MSBuildProjectExtensionsPath) diff --git a/src/NuGet.Core/NuGet.Build.Tasks/ErrorForMismatchRestoreOutputPathTask.cs b/src/NuGet.Core/NuGet.Build.Tasks/ErrorForMismatchRestoreOutputPathTask.cs new file mode 100644 index 00000000000..93d2cf4eb1b --- /dev/null +++ b/src/NuGet.Core/NuGet.Build.Tasks/ErrorForMismatchRestoreOutputPathTask.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; +using NuGet.Commands; + +namespace NuGet.Build.Tasks +{ + public class ErrorForMismatchRestoreOutputPathTask : Task + { + [Required] + public string RestoreOutputAbsolutePath { get; set; } + + [Required] + public string MSBuildProjectExtensionsPath { get; set; } + + public override bool Execute() + { + if (RestoreOutputAbsolutePath != MSBuildProjectExtensionsPath) + { + // The RestoreOutputPath, which resolved to '{0}', did not match the MSBuildProjectExtensionsPath, which was '{1}'. These properties must match in order for assets from NuGet restore to be applied correctly when building. + var log = new MSBuildLogger(Log); + var message = MSBuildRestoreUtility.GetErrorForRestoreOutputPathMismatch(RestoreOutputAbsolutePath, MSBuildProjectExtensionsPath); + log.Log(message); + } + + return true; + } + } +} diff --git a/src/NuGet.Core/NuGet.Build.Tasks/NuGet.targets b/src/NuGet.Core/NuGet.Build.Tasks/NuGet.targets index 2986d474774..eb1663ad8f1 100644 --- a/src/NuGet.Core/NuGet.Build.Tasks/NuGet.targets +++ b/src/NuGet.Core/NuGet.Build.Tasks/NuGet.targets @@ -93,6 +93,7 @@ Copyright (c) .NET Foundation. All rights reserved. + - $(BaseIntermediateOutputPath) + $(MSBuildProjectExtensionsPath) + + + + + + + true + + + + - + + $(MSBuildProjectExtensionsPath) + + + $(BaseIntermediateOutputPath) + From b54ed699dfc68bf422b702fced06f3e434dcbfaf Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Tue, 20 Mar 2018 15:09:49 -0700 Subject: [PATCH 09/12] Update tests to look in obj folder for assets file --- .../Dotnet.Integration.Test/DotnetToolTests.cs | 10 +++++----- .../MsbuilldIntegrationTestFixture.cs | 2 -- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetToolTests.cs b/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetToolTests.cs index 74520b97a22..6b462b0b9aa 100644 --- a/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetToolTests.cs +++ b/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetToolTests.cs @@ -111,7 +111,7 @@ public void DotnetToolTests_BasicDotnetToolRestore_Succeeds(string tfm) // Assert Assert.True(result.Item1 == 0, result.AllOutput); // Verify the assets file - var lockFile = LockFileUtilities.GetLockFile(Path.Combine(testDirectory, projectName, "project.assets.json"), NullLogger.Instance); + var lockFile = LockFileUtilities.GetLockFile(Path.Combine(testDirectory, projectName, "obj", "project.assets.json"), NullLogger.Instance); Assert.NotNull(lockFile); Assert.Equal(2, lockFile.Targets.Count); var ridTargets = lockFile.Targets.Where(e => e.RuntimeIdentifier != null ? e.RuntimeIdentifier.Equals(rid, StringComparison.CurrentCultureIgnoreCase) : false); @@ -195,7 +195,7 @@ public void DotnetToolTests_BasicDotnetToolRestore_WithJsonCompatibleAssets_Succ // Assert Assert.True(result.Item1 == 0, result.AllOutput); // Verify the assets file - var lockFile = LockFileUtilities.GetLockFile(Path.Combine(testDirectory, projectName, "project.assets.json"), NullLogger.Instance); + var lockFile = LockFileUtilities.GetLockFile(Path.Combine(testDirectory, projectName, "obj", "project.assets.json"), NullLogger.Instance); Assert.NotNull(lockFile); Assert.Equal(2, lockFile.Targets.Count); var ridTargets = lockFile.Targets.Where(e => e.RuntimeIdentifier != null ? e.RuntimeIdentifier.Equals(rid, StringComparison.CurrentCultureIgnoreCase) : false); @@ -243,7 +243,7 @@ public void DotnetToolTests_PackageWithRuntimeJson_RuntimeIdentifierAny_Succeeds // Assert Assert.True(result.Item1 == 0, result.AllOutput); // Verify the assets file - var lockFile = LockFileUtilities.GetLockFile(Path.Combine(testDirectory, projectName, "project.assets.json"), NullLogger.Instance); + var lockFile = LockFileUtilities.GetLockFile(Path.Combine(testDirectory, projectName, "obj", "project.assets.json"), NullLogger.Instance); Assert.NotNull(lockFile); Assert.Equal(2, lockFile.Targets.Count); var ridTargets = lockFile.Targets.Where(e => e.RuntimeIdentifier != null ? e.RuntimeIdentifier.Equals(projectRID, StringComparison.CurrentCultureIgnoreCase) : false); @@ -384,7 +384,7 @@ public void DotnetToolTests_ToolWithPlatformPackage_Succeeds(string tfm, string // Assert Assert.True(result.Item1 == 0, result.AllOutput); - var lockFile = LockFileUtilities.GetLockFile(Path.Combine(testDirectory, projectName, "project.assets.json"), NullLogger.Instance); + var lockFile = LockFileUtilities.GetLockFile(Path.Combine(testDirectory, projectName, "obj", "project.assets.json"), NullLogger.Instance); Assert.NotNull(lockFile); Assert.Equal(2, lockFile.Targets.Count); var ridTargets = lockFile.Targets.Where(e => e.RuntimeIdentifier != null ? e.RuntimeIdentifier.Equals(projectRid, StringComparison.CurrentCultureIgnoreCase) : false); @@ -504,7 +504,7 @@ public void DotnetToolTests_BasicDotnetToolRestoreWithNestedValues_Succeeds(stri // Assert Assert.True(result.Item1 == 0, result.AllOutput); // Verify the assets file - var lockFile = LockFileUtilities.GetLockFile(Path.Combine(testDirectory, projectName, "project.assets.json"), NullLogger.Instance); + var lockFile = LockFileUtilities.GetLockFile(Path.Combine(testDirectory, projectName, "obj", "project.assets.json"), NullLogger.Instance); Assert.NotNull(lockFile); Assert.Equal(2, lockFile.Targets.Count); var ridTargets = lockFile.Targets.Where(e => e.RuntimeIdentifier != null ? e.RuntimeIdentifier.Equals(rid, StringComparison.CurrentCultureIgnoreCase) : false); diff --git a/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/MsbuilldIntegrationTestFixture.cs b/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/MsbuilldIntegrationTestFixture.cs index c5aa04ed303..2e3b234ff71 100644 --- a/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/MsbuilldIntegrationTestFixture.cs +++ b/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/MsbuilldIntegrationTestFixture.cs @@ -80,7 +80,6 @@ internal void CreateDotnetToolProject(string solutionRoot, string projectName, s var projectFileName = Path.Combine(workingDirectory, projectName + ".csproj"); var restorePackagesPath = Path.Combine(workingDirectory, "tools", "packages"); - var baseIntermediatepath = Path.Combine(workingDirectory); var restoreSolutionDirectory = workingDirectory; var packageReference = string.Empty; foreach (var package in packages) { @@ -94,7 +93,6 @@ internal void CreateDotnetToolProject(string solutionRoot, string projectName, s {rid} {restorePackagesPath} - {baseIntermediatepath} {restoreSolutionDirectory} {source} From d6814b01d005cce7704e639623c8710802fabf90 Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Wed, 21 Mar 2018 16:12:28 -0700 Subject: [PATCH 10/12] Refactor restore output and cache path flow, fix tests --- .../Projects/LegacyPackageReferenceProject.cs | 20 +++++++++---- .../Projects/VsProjectJsonNuGetProject.cs | 13 +++++---- .../Strings.Designer.cs | 6 ++-- .../Strings.resx | 6 ++-- .../NuGet.Build.Tasks/NuGet.targets | 22 ++++++++++----- .../DependencyGraphSpecRequestProvider.cs | 8 ++++-- .../RequestFactory/RestoreArgs.cs | 4 --- .../RestoreCommand/RestoreCommand.cs | 8 +++--- .../Utility/MSBuildRestoreUtility.cs | 1 + .../Utility/NoOpRestoreUtilities.cs | 28 +++++++++---------- .../Projects/ProjectBuildProperties.cs | 1 + .../Projects/ProjectJsonNuGetProject.cs | 13 +++++---- .../ProjectRestoreMetadata.cs | 8 +++--- 13 files changed, 78 insertions(+), 60 deletions(-) diff --git a/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/LegacyPackageReferenceProject.cs b/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/LegacyPackageReferenceProject.cs index 3d7bb07c792..705b88eb1e6 100644 --- a/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/LegacyPackageReferenceProject.cs +++ b/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/LegacyPackageReferenceProject.cs @@ -91,14 +91,23 @@ private async Task GetAssetsFilePathAsync(bool shouldThrow) { await _threadingService.JoinableTaskFactory.SwitchToMainThreadAsync(); - var baseIntermediatePath = GetMSBuildProjectExtensionsPath(shouldThrow); + var msbuildProjectExtensionsPath = GetMSBuildProjectExtensionsPath(shouldThrow); - if (baseIntermediatePath == null) + if (msbuildProjectExtensionsPath == null) { return null; } - return Path.Combine(baseIntermediatePath, LockFileFormat.AssetsFileName); + return Path.Combine(msbuildProjectExtensionsPath, LockFileFormat.AssetsFileName); + } + + private async Task GetAssetsCacheFolderAsync(bool shouldThrow) + { + await _threadingService.JoinableTaskFactory.SwitchToMainThreadAsync(); + + var msbuildProjectExtensionsPath = GetMSBuildProjectExtensionsPath(shouldThrow); + + return msbuildProjectExtensionsPath; } #endregion BuildIntegratedNuGetProject @@ -175,7 +184,8 @@ private string GetMSBuildProjectExtensionsPath(bool shouldThrow = true) if (shouldThrow) { throw new InvalidDataException(string.Format( - Strings.MSBuildProjectExtensionsPathNotFound, + Strings.MSBuildPropertyNotFound, + ProjectBuildProperties.MSBuildProjectExtensionsPath, _vsProjectAdapter.ProjectDirectory)); } @@ -352,7 +362,7 @@ private async Task GetPackageSpecAsync(ISettings settings) } }, SkipContentFileWrite = true, - CacheFilePath = await GetCacheFilePathAsync(), + AssetsCacheFolder = await GetAssetsCacheFolderAsync(true), PackagesPath = GetPackagesPath(settings), Sources = GetSources(settings), FallbackFolders = GetFallbackFolders(settings), diff --git a/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/VsProjectJsonNuGetProject.cs b/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/VsProjectJsonNuGetProject.cs index 61e82b521dd..eff5cedfef0 100644 --- a/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/VsProjectJsonNuGetProject.cs +++ b/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/VsProjectJsonNuGetProject.cs @@ -39,23 +39,24 @@ public VsProjectJsonNuGetProject( ProjectServices = projectServices; } - protected override async Task GetMSBuildProjectExtensionsPathAsync() + protected async Task GetBaseIntermediateOutputPathAsync() { - var msbuildProjectExtensionsPath = await ProjectServices.BuildProperties.GetPropertyValueAsync(ProjectBuildProperties.MSBuildProjectExtensionsPath); + var baseIntermediateOutputPath = await ProjectServices.BuildProperties.GetPropertyValueAsync(ProjectBuildProperties.BaseIntermediateOutputPath); - if (string.IsNullOrEmpty(msbuildProjectExtensionsPath)) + if (string.IsNullOrEmpty(baseIntermediateOutputPath)) { throw new InvalidDataException(string.Format( - Strings.MSBuildProjectExtensionsPathNotFound, + Strings.MSBuildPropertyNotFound, + ProjectBuildProperties.BaseIntermediateOutputPath, MSBuildProjectPath)); } - return UriUtility.GetAbsolutePathFromFile(MSBuildProjectPath, msbuildProjectExtensionsPath); + return UriUtility.GetAbsolutePathFromFile(MSBuildProjectPath, baseIntermediateOutputPath); } public override async Task GetCacheFilePathAsync() { - return NoOpRestoreUtilities.GetProjectCacheFilePath(await GetMSBuildProjectExtensionsPathAsync(), MSBuildProjectPath); + return NoOpRestoreUtilities.GetProjectCacheFilePath(await GetBaseIntermediateOutputPathAsync(), MSBuildProjectPath); } protected override async Task UpdateInternalTargetFrameworkAsync() diff --git a/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Strings.Designer.cs b/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Strings.Designer.cs index 3febb11b0a3..1d11e6f1285 100644 --- a/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Strings.Designer.cs +++ b/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Strings.Designer.cs @@ -331,11 +331,11 @@ public static string InstallingPackage { } /// - /// Looks up a localized string similar to The MSBuildProjectExtensionsPath MSBuild property could not be found for project '{0}'.. + /// Looks up a localized string similar to The {0} MSBuild property could not be found for project '{1}'.. /// - public static string MSBuildProjectExtensionsPathNotFound { + public static string MSBuildPropertyNotFound { get { - return ResourceManager.GetString("MSBuildProjectExtensionsPathNotFound", resourceCulture); + return ResourceManager.GetString("MSBuildPropertyNotFound", resourceCulture); } } diff --git a/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Strings.resx b/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Strings.resx index bd3e9de317b..88dd232cc57 100644 --- a/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Strings.resx +++ b/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Strings.resx @@ -200,9 +200,9 @@ The operation failed as details for project {0} could not be loaded. - - The MSBuildProjectExtensionsPath MSBuild property could not be found for project '{0}'. - {0} is the full path to the project. + + The {0} MSBuild property could not be found for project '{1}'. + {0} is the name of the property that was not set. {1} is the full path to the project. The project '{0}' could not be cast to a build property storage interface, which is required to get MSBuild properties inside Visual Studio. diff --git a/src/NuGet.Core/NuGet.Build.Tasks/NuGet.targets b/src/NuGet.Core/NuGet.Build.Tasks/NuGet.targets index cc1069bb168..ef892da8bbe 100644 --- a/src/NuGet.Core/NuGet.Build.Tasks/NuGet.targets +++ b/src/NuGet.Core/NuGet.Build.Tasks/NuGet.targets @@ -593,17 +593,23 @@ Copyright (c) .NET Foundation. All rights reserved. targets import these via the MSBuildProjectExtensionsPath, so that's what the RestoreOutputPath should be. --> $(MSBuildProjectExtensionsPath) + + + + + - - $(BaseIntermediateOutputPath) + + $(BaseIntermediateOutputPath) - - + + + +