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/LegacyPackageReferenceProject.cs b/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/LegacyPackageReferenceProject.cs index 30a3aed64b1..705b88eb1e6 100644 --- a/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/LegacyPackageReferenceProject.cs +++ b/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/LegacyPackageReferenceProject.cs @@ -79,7 +79,7 @@ public override async Task GetAssetsFilePathAsync() public override async Task GetCacheFilePathAsync() { await _threadingService.JoinableTaskFactory.SwitchToMainThreadAsync(); - return NoOpRestoreUtilities.GetProjectCacheFilePath(cacheRoot: GetBaseIntermediatePath(), projectPath: _projectFullPath); + return NoOpRestoreUtilities.GetProjectCacheFilePath(cacheRoot: GetMSBuildProjectExtensionsPath(), projectPath: _projectFullPath); } public override async Task GetAssetsFilePathOrNullAsync() @@ -91,14 +91,23 @@ private async Task GetAssetsFilePathAsync(bool shouldThrow) { await _threadingService.JoinableTaskFactory.SwitchToMainThreadAsync(); - var baseIntermediatePath = GetBaseIntermediatePath(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 @@ -164,25 +173,26 @@ public override async Task UninstallPackageAsync( #endregion - private string GetBaseIntermediatePath(bool shouldThrow = true) + private string GetMSBuildProjectExtensionsPath(bool shouldThrow = true) { ThreadHelper.ThrowIfNotOnUIThread(); - var baseIntermediatePath = _vsProjectAdapter.BaseIntermediateOutputPath; + var msbuildProjectExtensionsPath = _vsProjectAdapter.MSBuildProjectExtensionsPath; - if (string.IsNullOrEmpty(baseIntermediatePath)) + if (string.IsNullOrEmpty(msbuildProjectExtensionsPath)) { if (shouldThrow) { throw new InvalidDataException(string.Format( - Strings.BaseIntermediateOutputPathNotFound, + Strings.MSBuildPropertyNotFound, + ProjectBuildProperties.MSBuildProjectExtensionsPath, _vsProjectAdapter.ProjectDirectory)); } return null; } - return baseIntermediatePath; + return msbuildProjectExtensionsPath; } private string GetPackagesPath(ISettings settings) @@ -337,7 +347,7 @@ private async Task GetPackageSpecAsync(ISettings settings) RestoreMetadata = new ProjectRestoreMetadata { ProjectStyle = ProjectStyle.PackageReference, - OutputPath = GetBaseIntermediatePath(), + OutputPath = GetMSBuildProjectExtensionsPath(), ProjectPath = _projectFullPath, ProjectName = projectName, ProjectUniqueName = _projectFullPath, @@ -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/VsProjectAdapter.cs b/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/VsProjectAdapter.cs index 94775ea035e..028dc6e53d2 100644 --- a/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/VsProjectAdapter.cs +++ b/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/VsProjectAdapter.cs @@ -35,18 +35,18 @@ internal class VsProjectAdapter : IVsProjectAdapter #region Properties - public string BaseIntermediateOutputPath + public string MSBuildProjectExtensionsPath { get { - var baseIntermediateOutputPath = BuildProperties.GetPropertyValue(ProjectBuildProperties.BaseIntermediateOutputPath); + var msbuildProjectExtensionsPath = BuildProperties.GetPropertyValue(ProjectBuildProperties.MSBuildProjectExtensionsPath); - if (string.IsNullOrEmpty(baseIntermediateOutputPath)) + if (string.IsNullOrEmpty(msbuildProjectExtensionsPath)) { return null; } - return Path.Combine(ProjectDirectory, baseIntermediateOutputPath); + return Path.Combine(ProjectDirectory, msbuildProjectExtensionsPath); } } @@ -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.PackageManagement.VisualStudio/Projects/VsProjectJsonNuGetProject.cs b/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/VsProjectJsonNuGetProject.cs index c0a6647d5df..be1d7910a45 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 GetBaseIntermediatePathAsync() + protected override async Task GetBaseIntermediateOutputPathAsync() { - var baseIntermediatePath = await ProjectServices.BuildProperties.GetPropertyValueAsync(ProjectBuildProperties.BaseIntermediateOutputPath); + var baseIntermediateOutputPath = await ProjectServices.BuildProperties.GetPropertyValueAsync(ProjectBuildProperties.BaseIntermediateOutputPath); - if (string.IsNullOrEmpty(baseIntermediatePath)) + if (string.IsNullOrEmpty(baseIntermediateOutputPath)) { throw new InvalidDataException(string.Format( - Strings.BaseIntermediateOutputPathNotFound, + Strings.MSBuildPropertyNotFound, + ProjectBuildProperties.BaseIntermediateOutputPath, MSBuildProjectPath)); } - return UriUtility.GetAbsolutePathFromFile(MSBuildProjectPath, baseIntermediatePath); + return UriUtility.GetAbsolutePathFromFile(MSBuildProjectPath, baseIntermediateOutputPath); } public override async Task GetCacheFilePathAsync() { - return NoOpRestoreUtilities.GetProjectCacheFilePath(await GetBaseIntermediatePathAsync(), 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 5efa9a98f17..1d11e6f1285 100644 --- a/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Strings.Designer.cs +++ b/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Strings.Designer.cs @@ -114,15 +114,6 @@ public static string Argument_Must_Be_GreaterThanOrEqualTo { } } - /// - /// Looks up a localized string similar to The BaseIntermediateOutputPath MSBuild property could not be found for project '{0}'.. - /// - public static string BaseIntermediateOutputPathNotFound { - get { - return ResourceManager.GetString("BaseIntermediateOutputPathNotFound", resourceCulture); - } - } - /// /// Looks up a localized string similar to NuGet operation failed. /// @@ -339,6 +330,15 @@ public static string InstallingPackage { } } + /// + /// Looks up a localized string similar to The {0} MSBuild property could not be found for project '{1}'.. + /// + public static string MSBuildPropertyNotFound { + get { + return ResourceManager.GetString("MSBuildPropertyNotFound", resourceCulture); + } + } + /// /// Looks up a localized string similar to Package stream should be seekable. /// diff --git a/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Strings.resx b/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Strings.resx index 297d41eb99e..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 BaseIntermediateOutputPath 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.Clients/NuGet.SolutionRestoreManager/VsSolutionRestoreService.cs b/src/NuGet.Clients/NuGet.SolutionRestoreManager/VsSolutionRestoreService.cs index 3498f508966..44816ab786e 100644 --- a/src/NuGet.Clients/NuGet.SolutionRestoreManager/VsSolutionRestoreService.cs +++ b/src/NuGet.Clients/NuGet.SolutionRestoreManager/VsSolutionRestoreService.cs @@ -284,10 +284,11 @@ private static PackageSpec ToPackageSpec(ProjectNames projectNames, IVsProjectRe treatWarningsAsErrors: GetNonEvaluatedPropertyOrNull(projectRestoreInfo.TargetFrameworks, TreatWarningsAsErrors, e => e), warningsAsErrors: GetNonEvaluatedPropertyOrNull(projectRestoreInfo.TargetFrameworks, WarningsAsErrors, e => e), noWarn: GetNonEvaluatedPropertyOrNull(projectRestoreInfo.TargetFrameworks, NoWarn, e => e)), - CacheFilePath = NoOpRestoreUtilities.GetProjectCacheFilePath(cacheRoot: outputPath, projectPath: projectFullPath) + AssetsCacheFolder = outputPath }, RuntimeGraph = GetRuntimeGraph(projectRestoreInfo), RestoreSettings = new ProjectRestoreSettings() { HideWarningsAndErrors = true } + }; return packageSpec; diff --git a/src/NuGet.Clients/NuGet.VisualStudio.Common/IVsProjectAdapter.cs b/src/NuGet.Clients/NuGet.VisualStudio.Common/IVsProjectAdapter.cs index e2dcc2cc173..5369f6dfea9 100644 --- a/src/NuGet.Clients/NuGet.VisualStudio.Common/IVsProjectAdapter.cs +++ b/src/NuGet.Clients/NuGet.VisualStudio.Common/IVsProjectAdapter.cs @@ -22,9 +22,9 @@ public interface IVsProjectAdapter string AssetTargetFallback { get; } /// - /// BaseIntermediateOutputPath project property (e.g. c:\projFoo\obj) + /// MSBuildProjectExtensionsPath project property (e.g. c:\projFoo\obj) /// - string BaseIntermediateOutputPath { get; } + string MSBuildProjectExtensionsPath { get; } IProjectBuildProperties BuildProperties { get; } 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.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/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/NuGet.targets b/src/NuGet.Core/NuGet.Build.Tasks/NuGet.targets index 2986d474774..ef892da8bbe 100644 --- a/src/NuGet.Core/NuGet.Build.Tasks/NuGet.targets +++ b/src/NuGet.Core/NuGet.Build.Tasks/NuGet.targets @@ -414,6 +414,25 @@ Copyright (c) .NET Foundation. All rights reserved. + + + + + + true + + + + - - $(BaseIntermediateOutputPath) + + + $(MSBuildProjectExtensionsPath) - + + + + + $(BaseIntermediateOutputPath) + + + + + + + {restorePackagesPath} - {baseIntermediatepath} {restoreSolutionDirectory} {source} 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.ProjectModel.Test/PackageSpecCloningTests.cs b/test/NuGet.Core.Tests/NuGet.ProjectModel.Test/PackageSpecCloningTests.cs index c8eb4481a40..75eba731c6c 100644 --- a/test/NuGet.Core.Tests/NuGet.ProjectModel.Test/PackageSpecCloningTests.cs +++ b/test/NuGet.Core.Tests/NuGet.ProjectModel.Test/PackageSpecCloningTests.cs @@ -362,7 +362,7 @@ private ProjectRestoreMetadata CreateProjectRestoreMetadata() originalProjectRestoreMetadata.ProjectName = "ProjectName"; originalProjectRestoreMetadata.ProjectUniqueName = "ProjectUniqueName"; originalProjectRestoreMetadata.PackagesPath = "PackagesPath"; - originalProjectRestoreMetadata.CacheFilePath = "CacheFilePath"; + originalProjectRestoreMetadata.AssetsCacheFolder = "AssetsCacheFolder"; originalProjectRestoreMetadata.CrossTargeting = true; originalProjectRestoreMetadata.LegacyPackagesDirectory = true; originalProjectRestoreMetadata.ValidateRuntimeAssets = true; 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/SimpleTestSetup/SimpleTestProjectContext.cs b/test/TestUtilities/Test.Utility/SimpleTestSetup/SimpleTestProjectContext.cs index 05a1af743d3..e1dc5abc496 100644 --- a/test/TestUtilities/Test.Utility/SimpleTestSetup/SimpleTestProjectContext.cs +++ b/test/TestUtilities/Test.Utility/SimpleTestSetup/SimpleTestProjectContext.cs @@ -60,7 +60,7 @@ public SimpleTestProjectContext(string projectName, ProjectStyle type, string so public string ProjectPath { get; set; } /// - /// Base intermediate directory path + /// MSBuildProjectExtensionsPath /// public string OutputPath { get; set; } @@ -396,7 +396,7 @@ public XDocument GetXML() ProjectFileUtils.AddProperties(xml, new Dictionary() { { "ProjectGuid", "{" + ProjectGuid.ToString() + "}" }, - { "BaseIntermediateOutputPath", OutputPath }, + { "MSBuildProjectExtensionsPath", OutputPath }, { "AssemblyName", ProjectName } }); 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)