From 544778c501f4bd48109b621f867bf896d050bf88 Mon Sep 17 00:00:00 2001 From: Forgind <12969783+Forgind@users.noreply.github.com> Date: Tue, 26 Nov 2024 08:57:30 -0500 Subject: [PATCH 01/17] Add command line validation For 'workloadVersionArgument's that aren't really workload version arguments --- .../search/WorkloadSearchVersionsCommandParser.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Cli/dotnet/commands/dotnet-workload/search/WorkloadSearchVersionsCommandParser.cs b/src/Cli/dotnet/commands/dotnet-workload/search/WorkloadSearchVersionsCommandParser.cs index d40d53193457..f3dd59e64bd0 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/search/WorkloadSearchVersionsCommandParser.cs +++ b/src/Cli/dotnet/commands/dotnet-workload/search/WorkloadSearchVersionsCommandParser.cs @@ -53,6 +53,19 @@ private static CliCommand ConstructCommand() } }); + command.Validators.Add(result => + { + var versionArgument = result.GetValue(WorkloadVersionArgument); + if (versionArgument is not null) + { + var coreComponents = versionArgument.Split(['-', '+'], 2)[0].Split('.'); + if (coreComponents.Length != 3 && coreComponents.Length != 4) + { + result.AddError(string.Format(CommandLineValidation.LocalizableStrings.UnrecognizedCommandOrArgument, versionArgument)); + } + } + }); + command.SetAction(parseResult => new WorkloadSearchVersionsCommand(parseResult).Execute()); return command; From f23a03f3923ad149468b05c3fb9202114ccffe3f Mon Sep 17 00:00:00 2001 From: Forgind <12969783+Forgind@users.noreply.github.com> Date: Tue, 26 Nov 2024 17:44:49 -0500 Subject: [PATCH 02/17] Feedback --- .../WorkloadSearchVersionsCommandParser.cs | 4 ++-- src/Common/WorkloadSetVersion.cs | 13 ++++++++++++- .../GivenDotnetWorkloadSearch.cs | 16 ++++++++++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/Cli/dotnet/commands/dotnet-workload/search/WorkloadSearchVersionsCommandParser.cs b/src/Cli/dotnet/commands/dotnet-workload/search/WorkloadSearchVersionsCommandParser.cs index f3dd59e64bd0..aa85989e35d6 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/search/WorkloadSearchVersionsCommandParser.cs +++ b/src/Cli/dotnet/commands/dotnet-workload/search/WorkloadSearchVersionsCommandParser.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.CommandLine; +using Microsoft.DotNet.Workloads.Workload; using Microsoft.DotNet.Workloads.Workload.Search; using LocalizableStrings = Microsoft.DotNet.Workloads.Workload.Search.LocalizableStrings; @@ -58,8 +59,7 @@ private static CliCommand ConstructCommand() var versionArgument = result.GetValue(WorkloadVersionArgument); if (versionArgument is not null) { - var coreComponents = versionArgument.Split(['-', '+'], 2)[0].Split('.'); - if (coreComponents.Length != 3 && coreComponents.Length != 4) + if (!WorkloadSetVersion.IsWorkloadSetPackageVersion(versionArgument)) { result.AddError(string.Format(CommandLineValidation.LocalizableStrings.UnrecognizedCommandOrArgument, versionArgument)); } diff --git a/src/Common/WorkloadSetVersion.cs b/src/Common/WorkloadSetVersion.cs index 2057b0620af7..b15cfdc0a171 100644 --- a/src/Common/WorkloadSetVersion.cs +++ b/src/Common/WorkloadSetVersion.cs @@ -8,9 +8,20 @@ namespace Microsoft.DotNet.Workloads.Workload { static class WorkloadSetVersion { + public static bool IsWorkloadSetPackageVersion(string workloadSetVersion) + { + + string[] sections = workloadSetVersion.Split(['-', '+'], 2); + string versionCore = sections[0]; + string? preReleaseOrBuild = sections.Length > 1 ? sections[1] : null; + + string[] coreComponents = versionCore.Split('.'); + return coreComponents.Length >= 3 && coreComponents.Length <= 4; + } + public static string ToWorkloadSetPackageVersion(string workloadSetVersion, out SdkFeatureBand sdkFeatureBand) { - string[] sections = workloadSetVersion.Split(new char[] { '-', '+' }, 2); + string[] sections = workloadSetVersion.Split(['-', '+'], 2); string versionCore = sections[0]; string? preReleaseOrBuild = sections.Length > 1 ? sections[1] : null; diff --git a/test/dotnet-workload-search.Tests/GivenDotnetWorkloadSearch.cs b/test/dotnet-workload-search.Tests/GivenDotnetWorkloadSearch.cs index 443781d46533..9e614502f0c7 100644 --- a/test/dotnet-workload-search.Tests/GivenDotnetWorkloadSearch.cs +++ b/test/dotnet-workload-search.Tests/GivenDotnetWorkloadSearch.cs @@ -28,6 +28,22 @@ public GivenDotnetWorkloadSearch(ITestOutputHelper log) : base(log) _reporter = new BufferedReporter(); } + [Theory] + [InlineData("--invalidArgument")] + [InlineData("notAVersion")] + [InlineData("1.2")] // too short + [InlineData("1.2.3.4.5")] // too long + [InlineData("1.2-3.4")] // numbers after [-, +] don't count + public void GivenInvalidArgumentToWorkloadSearchVersionItFailsCleanly(string argument) + { + _reporter.Clear(); + var parseResult = Parser.Instance.Parse($"dotnet workload search version {argument}"); + var workloadResolver = new MockWorkloadResolver(Enumerable.Empty()); + var workloadResolverFactory = new MockWorkloadResolverFactory(dotnetPath: null, "9.0.100", workloadResolver); + var command = () => new WorkloadSearchVersionsCommand(parseResult, _reporter, workloadResolverFactory); + command.Should().Throw(); + } + [Fact] public void GivenNoWorkloadsAreInstalledSearchIsEmpty() { From 2c86f58b098147e268e4a19ce52294128f0b4b2a Mon Sep 17 00:00:00 2001 From: Forgind <12969783+Forgind@users.noreply.github.com> Date: Mon, 2 Dec 2024 19:39:54 -0500 Subject: [PATCH 03/17] Exclude private assets --- .../DependencyContextBuilder.cs | 39 +++++++++++++++++++ .../GenerateDepsFile.cs | 3 ++ .../targets/Microsoft.NET.Publish.targets | 1 + .../targets/Microsoft.NET.Sdk.targets | 1 + 4 files changed, 44 insertions(+) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/DependencyContextBuilder.cs b/src/Tasks/Microsoft.NET.Build.Tasks/DependencyContextBuilder.cs index 463270e87c14..f358a6d65ba8 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/DependencyContextBuilder.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/DependencyContextBuilder.cs @@ -22,6 +22,7 @@ internal class DependencyContextBuilder private Dictionary> _compileReferences; private Dictionary> _resolvedNuGetFiles; private Dictionary _referenceProjectInfos; + private IEnumerable _excludeFromPublishPackageIds; private Dictionary> _runtimePackAssets; private CompilationOptions _compilationOptions; private string _referenceAssembliesPath; @@ -204,6 +205,12 @@ public DependencyContextBuilder WithReferenceProjectInfos(Dictionary excludeFromPublishPackageIds) + { + _excludeFromPublishPackageIds = excludeFromPublishPackageIds; + return this; + } + public DependencyContextBuilder WithMainProjectInDepsFile(bool includeMainProjectInDepsFile) { _includeMainProjectInDepsFile = includeMainProjectInDepsFile; @@ -814,6 +821,38 @@ private void CalculateExcludedLibraries() { _dependencyLibraries[packageToExcludeFromRuntime].ExcludeFromRuntime = true; } + + // Include transitive dependencies of all top-level dependencies + Dictionary includedDependencies = new(StringComparer.OrdinalIgnoreCase); + Stack dependencyListToWalk = new(_mainProjectDependencies); + + while (dependencyListToWalk.Count != 0) + { + var dependencyName = dependencyListToWalk.Pop(); + if (!includedDependencies.ContainsKey(dependencyName) && _excludeFromPublishPackageIds?.Contains(dependencyName) != true) + { + // There may not be a library in the assets file if a referenced project has + // PrivateAssets="all" for a package reference, and there is a package in the graph + // that depends on the same package. + if (_dependencyLibraries.TryGetValue(dependencyName, out var dependencyLibrary)) + { + includedDependencies.Add(dependencyName, dependencyLibrary); + foreach (var newDependency in _libraryDependencies[dependencyName]) + { + dependencyListToWalk.Push(newDependency.Name); + } + } + } + } + + foreach (var dependencyLibrary in _dependencyLibraries.Values) + { + if (!includedDependencies.ContainsKey(dependencyLibrary.Name)) + { + dependencyLibrary.ExcludeFromCompilation = true; + dependencyLibrary.ExcludeFromRuntime = true; + } + } } private string GetReferenceLibraryName(ReferenceInfo reference) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/GenerateDepsFile.cs b/src/Tasks/Microsoft.NET.Build.Tasks/GenerateDepsFile.cs index 816b94b2b580..549376a1f9c5 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/GenerateDepsFile.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/GenerateDepsFile.cs @@ -64,6 +64,8 @@ public class GenerateDepsFile : TaskBase public ITaskItem CompilerOptions { get; set; } + public ITaskItem[] ExcludeFromPublishPackageReferences { get; set; } = Array.Empty(); + public ITaskItem[] RuntimeStorePackages { get; set; } // NuGet compilation assets @@ -232,6 +234,7 @@ bool ShouldIncludeRuntimeAsset(ITaskItem item) .WithDirectReferences(directReferences) .WithDependencyReferences(dependencyReferences) .WithReferenceProjectInfos(referenceProjects) + .WithExcludeFromPublishAssets(PackageReferenceConverter.GetPackageIds(ExcludeFromPublishPackageReferences)) .WithRuntimePackAssets(runtimePackAssets) .WithCompilationOptions(compilationOptions) .WithReferenceAssembliesPath(FrameworkReferenceResolver.GetDefaultReferenceAssembliesPath()) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets index 4a0f8fa3fc29..eaf2b5011e62 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets @@ -1236,6 +1236,7 @@ Copyright (c) .NET Foundation. All rights reserved. PlatformLibraryName="$(MicrosoftNETPlatformLibrary)" RuntimeFrameworks="@(RuntimeFramework)" CompilerOptions="@(DependencyFileCompilerOptions)" + ExcludeFromPublishPackageReferences="@(_ExcludeFromPublishPackageReference)" RuntimeStorePackages="@(RuntimeStorePackages)" CompileReferences="@(ResolvedCompileFileDefinitions)" ResolvedNuGetFiles="@(_ResolvedNuGetFilesForPublish)" diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets index 6fa4bc2d0782..9ec1d30f3c2f 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets @@ -338,6 +338,7 @@ Copyright (c) .NET Foundation. All rights reserved. PlatformLibraryName="$(MicrosoftNETPlatformLibrary)" RuntimeFrameworks="@(RuntimeFramework)" CompilerOptions="@(DependencyFileCompilerOptions)" + ExcludeFromPublishPackageReferences="@(_ExcludeFromPublishPackageReference)" CompileReferences="@(ResolvedCompileFileDefinitions)" ResolvedNuGetFiles="@(NativeCopyLocalItems);@(ResourceCopyLocalItems);@(RuntimeCopyLocalItems)" UserRuntimeAssemblies="@(UserRuntimeAssembly)" From 31fe4b0724fe545b57b6d8d8479fb2f1df926518 Mon Sep 17 00:00:00 2001 From: Forgind <12969783+Forgind@users.noreply.github.com> Date: Mon, 2 Dec 2024 21:10:06 -0500 Subject: [PATCH 04/17] Attempt to resolve workload gc bug --- .../dotnet-workload/WorkloadUtilities.cs | 37 +++++++++++++++++++ .../install/WorkloadGarbageCollector.cs | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/Cli/dotnet/commands/dotnet-workload/WorkloadUtilities.cs diff --git a/src/Cli/dotnet/commands/dotnet-workload/WorkloadUtilities.cs b/src/Cli/dotnet/commands/dotnet-workload/WorkloadUtilities.cs new file mode 100644 index 000000000000..cffbaf893fc8 --- /dev/null +++ b/src/Cli/dotnet/commands/dotnet-workload/WorkloadUtilities.cs @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Deployment.DotNet.Releases; + +namespace Microsoft.DotNet.Workloads.Workload +{ + internal class WorkloadUtilities + { + internal static int VersionCompare(string first, string second) + { + if (first.Equals(second)) + { + return 0; + } + + var firstDash = first.IndexOf('-'); + var secondDash = second.IndexOf('-'); + firstDash = firstDash < 0 ? first.Length : firstDash; + secondDash = secondDash < 0 ? second.Length : secondDash; + + var firstVersion = new Version(first.Substring(0, firstDash)); + var secondVersion = new Version(second.Substring(0, secondDash)); + + var comparison = firstVersion.CompareTo(secondVersion); + if (comparison != 0) + { + return comparison; + } + + var modifiedFirst = "1.1.1" + (firstDash == first.Length ? string.Empty : first.Substring(firstDash)); + var modifiedSecond = "1.1.1" + (secondDash == second.Length ? string.Empty : second.Substring(secondDash)); + + return new ReleaseVersion(modifiedFirst).CompareTo(new ReleaseVersion(modifiedSecond)); + } + } +} diff --git a/src/Cli/dotnet/commands/dotnet-workload/install/WorkloadGarbageCollector.cs b/src/Cli/dotnet/commands/dotnet-workload/install/WorkloadGarbageCollector.cs index d9d72f80154f..0b74c06101d6 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/install/WorkloadGarbageCollector.cs +++ b/src/Cli/dotnet/commands/dotnet-workload/install/WorkloadGarbageCollector.cs @@ -115,7 +115,7 @@ void GarbageCollectWorkloadSets() // If there isn't a rollback state file, don't garbage collect the latest workload set installed for the feature band if (installedWorkloadSets.Any()) { - var latestWorkloadSetVersion = installedWorkloadSets.Keys.MaxBy(k => new ReleaseVersion(k)); + var latestWorkloadSetVersion = installedWorkloadSets.Keys.Aggregate((s1, s2) => WorkloadUtilities.VersionCompare(s1, s2) >= 0 ? s1 : s2); _workloadSets[latestWorkloadSetVersion] = GCAction.Keep; _verboseReporter.WriteLine($"GC: Keeping latest installed workload set version {latestWorkloadSetVersion}"); } From 7875a5c7ef06ed0f42f2bb0efc37770a803eaa09 Mon Sep 17 00:00:00 2001 From: Forgind <12969783+Forgind@users.noreply.github.com> Date: Tue, 3 Dec 2024 12:36:10 -0500 Subject: [PATCH 05/17] Fix bad test --- .../MvcBuildIntegrationTestLegacy.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Microsoft.NET.Sdk.Razor.Tests/MvcBuildIntegrationTestLegacy.cs b/test/Microsoft.NET.Sdk.Razor.Tests/MvcBuildIntegrationTestLegacy.cs index 1447b3977762..d80b56699761 100644 --- a/test/Microsoft.NET.Sdk.Razor.Tests/MvcBuildIntegrationTestLegacy.cs +++ b/test/Microsoft.NET.Sdk.Razor.Tests/MvcBuildIntegrationTestLegacy.cs @@ -113,9 +113,9 @@ public void Build_ProducesDepsFileWithCompilationContext_ButNoReferences() depsFile.Should().Exist(); var dependencyContext = ReadDependencyContext(depsFile.FullName); - // Ensure some compile references exist - var packageReference = dependencyContext.CompileLibraries.First(l => l.Name == "System.Runtime.CompilerServices.Unsafe"); - packageReference.Assemblies.Should().NotBeEmpty(); + // Ensure compile references from a PrivateAssets="all" PackageReference don't exist + var packageReference = dependencyContext.CompileLibraries.FirstOrDefault(l => l.Name == "System.Runtime.CompilerServices.Unsafe", defaultValue: null); + packageReference.Should().BeNull(); var projectReference = dependencyContext.CompileLibraries.First(l => l.Name == TestProjectName); projectReference.Assemblies.Should().NotBeEmpty(); From 09baaa738f95853be6807e0cd07800c64a869eca Mon Sep 17 00:00:00 2001 From: Forgind <12969783+Forgind@users.noreply.github.com> Date: Tue, 3 Dec 2024 12:39:06 -0500 Subject: [PATCH 06/17] Cleaner comparison --- .../dotnet/commands/dotnet-workload/WorkloadUtilities.cs | 6 +++--- .../SdkDirectoryWorkloadManifestProvider.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Cli/dotnet/commands/dotnet-workload/WorkloadUtilities.cs b/src/Cli/dotnet/commands/dotnet-workload/WorkloadUtilities.cs index cffbaf893fc8..0b3ab2fbbe11 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/WorkloadUtilities.cs +++ b/src/Cli/dotnet/commands/dotnet-workload/WorkloadUtilities.cs @@ -28,10 +28,10 @@ internal static int VersionCompare(string first, string second) return comparison; } - var modifiedFirst = "1.1.1" + (firstDash == first.Length ? string.Empty : first.Substring(firstDash)); - var modifiedSecond = "1.1.1" + (secondDash == second.Length ? string.Empty : second.Substring(secondDash)); + var modifiedFirst = new ReleaseVersion(1, 1, 1, firstDash == first.Length ? string.Empty : first.Substring(firstDash)); + var modifiedSecond = new ReleaseVersion(1, 1, 1, secondDash == second.Length ? string.Empty : second.Substring(secondDash)); - return new ReleaseVersion(modifiedFirst).CompareTo(new ReleaseVersion(modifiedSecond)); + return modifiedFirst.CompareTo(modifiedSecond); } } } diff --git a/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/SdkDirectoryWorkloadManifestProvider.cs b/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/SdkDirectoryWorkloadManifestProvider.cs index bcd9f3981028..19a1045cfc33 100644 --- a/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/SdkDirectoryWorkloadManifestProvider.cs +++ b/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/SdkDirectoryWorkloadManifestProvider.cs @@ -230,10 +230,10 @@ private static int VersionCompare(string first, string second) return comparison; } - var modifiedFirst = "1.1.1" + (firstDash == first.Length ? string.Empty : first.Substring(firstDash)); - var modifiedSecond = "1.1.1" + (secondDash == second.Length ? string.Empty : second.Substring(secondDash)); + var modifiedFirst = new ReleaseVersion(1, 1, 1, firstDash == first.Length ? string.Empty : first.Substring(firstDash)); + var modifiedSecond = new ReleaseVersion(1, 1, 1, secondDash == second.Length ? string.Empty : second.Substring(secondDash)); - return new ReleaseVersion(modifiedFirst).CompareTo(new ReleaseVersion(modifiedSecond)); + return modifiedFirst.CompareTo(modifiedSecond); } void ThrowExceptionIfManifestsNotAvailable() From ee67019dee2b6275e8e4c2761e017df4e23109c7 Mon Sep 17 00:00:00 2001 From: Forgind <12969783+Forgind@users.noreply.github.com> Date: Tue, 3 Dec 2024 14:21:06 -0500 Subject: [PATCH 07/17] Force overwrite --- .../install/FileBasedInstaller.cs | 34 ++++++++++++++----- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/src/Cli/dotnet/commands/dotnet-workload/install/FileBasedInstaller.cs b/src/Cli/dotnet/commands/dotnet-workload/install/FileBasedInstaller.cs index 6ba629c06799..1585c5e33f1f 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/install/FileBasedInstaller.cs +++ b/src/Cli/dotnet/commands/dotnet-workload/install/FileBasedInstaller.cs @@ -133,6 +133,11 @@ public async Task GetWorkloadSetContentsAsync(string workloadSetVer } public void InstallWorkloads(IEnumerable workloadIds, SdkFeatureBand sdkFeatureBand, ITransactionContext transactionContext, DirectoryPath? offlineCache = null) + { + InstallWorkloads(workloadIds, sdkFeatureBand, transactionContext, overwriteExistingPacks: false, offlineCache); + } + + public void InstallWorkloads(IEnumerable workloadIds, SdkFeatureBand sdkFeatureBand, ITransactionContext transactionContext, bool overwriteExistingPacks, DirectoryPath? offlineCache = null) { var packInfos = GetPacksInWorkloads(workloadIds); @@ -146,7 +151,11 @@ public void InstallWorkloads(IEnumerable workloadIds, SdkFeatureBand transactionContext.Run( action: () => { - if (!PackIsInstalled(packInfo)) + if (PackIsInstalled(packInfo) && !overwriteExistingPacks) + { + _reporter.WriteLine(string.Format(LocalizableStrings.WorkloadPackAlreadyInstalledMessage, packInfo.ResolvedPackageId, packInfo.Version)); + } + else { shouldRollBackPack = true; string packagePath; @@ -175,22 +184,30 @@ public void InstallWorkloads(IEnumerable workloadIds, SdkFeatureBand if (IsSingleFilePack(packInfo)) { - File.Copy(packagePath, packInfo.Path); + File.Copy(packagePath, packInfo.Path, overwrite: overwriteExistingPacks); } else { var tempExtractionDir = Path.Combine(_tempPackagesDir.Value, $"{packInfo.ResolvedPackageId}-{packInfo.Version}-extracted"); tempDirsToDelete.Add(tempExtractionDir); + + // This directory should have been deleted, but remove it just in case + if (overwriteExistingPacks && Directory.Exists(tempExtractionDir)) + { + Directory.Delete(tempExtractionDir, recursive: true); + } + Directory.CreateDirectory(tempExtractionDir); var packFiles = _nugetPackageDownloader.ExtractPackageAsync(packagePath, new DirectoryPath(tempExtractionDir)).GetAwaiter().GetResult(); + if (overwriteExistingPacks && Directory.Exists(packInfo.Path)) + { + Directory.Delete(packInfo.Path, recursive: true); + } + FileAccessRetrier.RetryOnMoveAccessFailure(() => DirectoryPath.MoveDirectory(tempExtractionDir, packInfo.Path)); } - } - else - { - _reporter.WriteLine(string.Format(LocalizableStrings.WorkloadPackAlreadyInstalledMessage, packInfo.ResolvedPackageId, packInfo.Version)); - } + } WritePackInstallationRecord(packInfo, sdkFeatureBand); }, @@ -237,8 +254,7 @@ public void InstallWorkloads(IEnumerable workloadIds, SdkFeatureBand public void RepairWorkloads(IEnumerable workloadIds, SdkFeatureBand sdkFeatureBand, DirectoryPath? offlineCache = null) { - // TODO: Actually re-extract the packs to fix any corrupted files. - CliTransaction.RunNew(context => InstallWorkloads(workloadIds, sdkFeatureBand, context, offlineCache)); + CliTransaction.RunNew(context => InstallWorkloads(workloadIds, sdkFeatureBand, context, overwriteExistingPacks: true, offlineCache)); } string GetManifestInstallDirForFeatureBand(string sdkFeatureBand) From 9bdf99c2987dfcbab51695b60b16a30b99ebf0a2 Mon Sep 17 00:00:00 2001 From: Forgind <12969783+Forgind@users.noreply.github.com> Date: Tue, 3 Dec 2024 15:01:07 -0500 Subject: [PATCH 08/17] string.Empty --> null --- src/Cli/dotnet/commands/dotnet-workload/WorkloadUtilities.cs | 4 ++-- .../SdkDirectoryWorkloadManifestProvider.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Cli/dotnet/commands/dotnet-workload/WorkloadUtilities.cs b/src/Cli/dotnet/commands/dotnet-workload/WorkloadUtilities.cs index 0b3ab2fbbe11..b621d0939767 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/WorkloadUtilities.cs +++ b/src/Cli/dotnet/commands/dotnet-workload/WorkloadUtilities.cs @@ -28,8 +28,8 @@ internal static int VersionCompare(string first, string second) return comparison; } - var modifiedFirst = new ReleaseVersion(1, 1, 1, firstDash == first.Length ? string.Empty : first.Substring(firstDash)); - var modifiedSecond = new ReleaseVersion(1, 1, 1, secondDash == second.Length ? string.Empty : second.Substring(secondDash)); + var modifiedFirst = new ReleaseVersion(1, 1, 1, firstDash == first.Length ? null : first.Substring(firstDash)); + var modifiedSecond = new ReleaseVersion(1, 1, 1, secondDash == second.Length ? null : second.Substring(secondDash)); return modifiedFirst.CompareTo(modifiedSecond); } diff --git a/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/SdkDirectoryWorkloadManifestProvider.cs b/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/SdkDirectoryWorkloadManifestProvider.cs index 19a1045cfc33..a56622cf5a69 100644 --- a/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/SdkDirectoryWorkloadManifestProvider.cs +++ b/src/Resolvers/Microsoft.NET.Sdk.WorkloadManifestReader/SdkDirectoryWorkloadManifestProvider.cs @@ -230,8 +230,8 @@ private static int VersionCompare(string first, string second) return comparison; } - var modifiedFirst = new ReleaseVersion(1, 1, 1, firstDash == first.Length ? string.Empty : first.Substring(firstDash)); - var modifiedSecond = new ReleaseVersion(1, 1, 1, secondDash == second.Length ? string.Empty : second.Substring(secondDash)); + var modifiedFirst = new ReleaseVersion(1, 1, 1, firstDash == first.Length ? null : first.Substring(firstDash)); + var modifiedSecond = new ReleaseVersion(1, 1, 1, secondDash == second.Length ? null : second.Substring(secondDash)); return modifiedFirst.CompareTo(modifiedSecond); } From c9d7a7666b8bdb5763541c3626005e8a13471fa5 Mon Sep 17 00:00:00 2001 From: Forgind <12969783+Forgind@users.noreply.github.com> Date: Tue, 3 Dec 2024 15:48:55 -0500 Subject: [PATCH 09/17] Target by framework --- .../MvcBuildIntegrationTestLegacy.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test/Microsoft.NET.Sdk.Razor.Tests/MvcBuildIntegrationTestLegacy.cs b/test/Microsoft.NET.Sdk.Razor.Tests/MvcBuildIntegrationTestLegacy.cs index d80b56699761..9c4d881277f0 100644 --- a/test/Microsoft.NET.Sdk.Razor.Tests/MvcBuildIntegrationTestLegacy.cs +++ b/test/Microsoft.NET.Sdk.Razor.Tests/MvcBuildIntegrationTestLegacy.cs @@ -113,9 +113,18 @@ public void Build_ProducesDepsFileWithCompilationContext_ButNoReferences() depsFile.Should().Exist(); var dependencyContext = ReadDependencyContext(depsFile.FullName); - // Ensure compile references from a PrivateAssets="all" PackageReference don't exist - var packageReference = dependencyContext.CompileLibraries.FirstOrDefault(l => l.Name == "System.Runtime.CompilerServices.Unsafe", defaultValue: null); - packageReference.Should().BeNull(); + if (TargetFramework.Equals("netcoreapp2.2")) + { + // Ensure compile references from a PrivateAssets="all" PackageReference don't exist + var packageReference = dependencyContext.CompileLibraries.FirstOrDefault(l => l.Name == "System.Runtime.CompilerServices.Unsafe", defaultValue: null); + packageReference.Should().BeNull(); + } + else + { + // Ensure some compile references exist + var packageReference = dependencyContext.CompileLibraries.First(l => l.Name == "System.Runtime.CompilerServices.Unsafe"); + packageReference.Assemblies.Should().NotBeEmpty(); + } var projectReference = dependencyContext.CompileLibraries.First(l => l.Name == TestProjectName); projectReference.Assemblies.Should().NotBeEmpty(); From 27f7f91c86016eec763f2d58ade480fbf4e1dcee Mon Sep 17 00:00:00 2001 From: Forgind <12969783+Forgind@users.noreply.github.com> Date: Tue, 3 Dec 2024 17:39:21 -0800 Subject: [PATCH 10/17] Update src/Tasks/Microsoft.NET.Build.Tasks/DependencyContextBuilder.cs Co-authored-by: Michael Yanni --- .../DependencyContextBuilder.cs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/DependencyContextBuilder.cs b/src/Tasks/Microsoft.NET.Build.Tasks/DependencyContextBuilder.cs index f358a6d65ba8..1f1c4c4a14d8 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/DependencyContextBuilder.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/DependencyContextBuilder.cs @@ -829,18 +829,17 @@ private void CalculateExcludedLibraries() while (dependencyListToWalk.Count != 0) { var dependencyName = dependencyListToWalk.Pop(); - if (!includedDependencies.ContainsKey(dependencyName) && _excludeFromPublishPackageIds?.Contains(dependencyName) != true) + // There may not be a library in the assets file if a referenced project has + // PrivateAssets="all" for a package reference, and there is a package in the graph + // that depends on the same package. + if (!includedDependencies.ContainsKey(dependencyName) && + _excludeFromPublishPackageIds?.Contains(dependencyName) != true && + _dependencyLibraries.TryGetValue(dependencyName, out var dependencyLibrary)) { - // There may not be a library in the assets file if a referenced project has - // PrivateAssets="all" for a package reference, and there is a package in the graph - // that depends on the same package. - if (_dependencyLibraries.TryGetValue(dependencyName, out var dependencyLibrary)) + includedDependencies.Add(dependencyName, dependencyLibrary); + foreach (var newDependency in _libraryDependencies[dependencyName]) { - includedDependencies.Add(dependencyName, dependencyLibrary); - foreach (var newDependency in _libraryDependencies[dependencyName]) - { - dependencyListToWalk.Push(newDependency.Name); - } + dependencyListToWalk.Push(newDependency.Name); } } } From 7c92aa32e814d051fada525f210d8c073aefe807 Mon Sep 17 00:00:00 2001 From: Forgind <12969783+Forgind@users.noreply.github.com> Date: Tue, 3 Dec 2024 20:51:29 -0500 Subject: [PATCH 11/17] Comments --- .../WorkloadSearchVersionsCommandParser.cs | 7 ++--- src/Common/WorkloadSetVersion.cs | 29 +++++++------------ 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/src/Cli/dotnet/commands/dotnet-workload/search/WorkloadSearchVersionsCommandParser.cs b/src/Cli/dotnet/commands/dotnet-workload/search/WorkloadSearchVersionsCommandParser.cs index aa85989e35d6..a9a4bbfa5186 100644 --- a/src/Cli/dotnet/commands/dotnet-workload/search/WorkloadSearchVersionsCommandParser.cs +++ b/src/Cli/dotnet/commands/dotnet-workload/search/WorkloadSearchVersionsCommandParser.cs @@ -57,12 +57,9 @@ private static CliCommand ConstructCommand() command.Validators.Add(result => { var versionArgument = result.GetValue(WorkloadVersionArgument); - if (versionArgument is not null) + if (versionArgument is not null && !WorkloadSetVersion.IsWorkloadSetPackageVersion(versionArgument)) { - if (!WorkloadSetVersion.IsWorkloadSetPackageVersion(versionArgument)) - { - result.AddError(string.Format(CommandLineValidation.LocalizableStrings.UnrecognizedCommandOrArgument, versionArgument)); - } + result.AddError(string.Format(CommandLineValidation.LocalizableStrings.UnrecognizedCommandOrArgument, versionArgument)); } }); diff --git a/src/Common/WorkloadSetVersion.cs b/src/Common/WorkloadSetVersion.cs index b15cfdc0a171..907b9f5b9f42 100644 --- a/src/Common/WorkloadSetVersion.cs +++ b/src/Common/WorkloadSetVersion.cs @@ -8,34 +8,29 @@ namespace Microsoft.DotNet.Workloads.Workload { static class WorkloadSetVersion { - public static bool IsWorkloadSetPackageVersion(string workloadSetVersion) + private static string[] SeparateCoreComponents(string workloadSetVersion, out string[] sections) { + sections = workloadSetVersion.Split(['-', '+'], 2); + return sections[0].Split('.'); + } - string[] sections = workloadSetVersion.Split(['-', '+'], 2); - string versionCore = sections[0]; - string? preReleaseOrBuild = sections.Length > 1 ? sections[1] : null; - - string[] coreComponents = versionCore.Split('.'); - return coreComponents.Length >= 3 && coreComponents.Length <= 4; + public static bool IsWorkloadSetPackageVersion(string workloadSetVersion) + { + int coreComponentsLength = SeparateCoreComponents(workloadSetVersion, out _).Length; + return coreComponentsLength >= 3 && coreComponentsLength <= 4; } public static string ToWorkloadSetPackageVersion(string workloadSetVersion, out SdkFeatureBand sdkFeatureBand) { - string[] sections = workloadSetVersion.Split(['-', '+'], 2); - string versionCore = sections[0]; - string? preReleaseOrBuild = sections.Length > 1 ? sections[1] : null; - - string[] coreComponents = versionCore.Split('.'); + string[] coreComponents = SeparateCoreComponents(workloadSetVersion, out string[] sections); string major = coreComponents[0]; string minor = coreComponents[1]; string patch = coreComponents[2]; - string packageVersion = $"{major}.{patch}."; if (coreComponents.Length == 3) { // No workload set patch version packageVersion += "0"; - // Use preview specifier (if any) from workload set version as part of SDK feature band sdkFeatureBand = new SdkFeatureBand(workloadSetVersion); } @@ -43,18 +38,16 @@ public static string ToWorkloadSetPackageVersion(string workloadSetVersion, out { // Workload set version has workload patch version (ie 4 components) packageVersion += coreComponents[3]; - // Don't include any preview specifiers in SDK feature band sdkFeatureBand = new SdkFeatureBand($"{major}.{minor}.{patch}"); } - if (preReleaseOrBuild != null) + if (sections.Length > 1) { // Figure out if we split on a '-' or '+' char separator = workloadSetVersion[sections[0].Length]; - packageVersion += separator + preReleaseOrBuild; + packageVersion += separator + sections[1]; } - return packageVersion; } From f5ce52e9eddd5b2e51cea8036025a059295c4ddc Mon Sep 17 00:00:00 2001 From: Forgind <12969783+Forgind@users.noreply.github.com> Date: Thu, 5 Dec 2024 17:45:16 -0500 Subject: [PATCH 12/17] Add test specifically for this case --- .../GivenThatWeWantToBuildADesktopLibrary.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopLibrary.cs b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopLibrary.cs index 127aaf3882cd..557741e430d5 100644 --- a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopLibrary.cs +++ b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopLibrary.cs @@ -225,6 +225,32 @@ public void It_can_preserve_compilation_context_and_reference_netstandard_librar } } + [Theory] + [InlineData("RazorSimpleMvc22", "netcoreapp2.2", "SimpleMvc22")] + [InlineData("DesktopReferencingNetStandardLibrary", "net46", "Library")] + public void PackageReferences_with_private_assets_do_not_appear_in_deps_file(string asset, string targetFramework, string exeName) + { + var testAsset = _testAssetsManager + .CopyTestAsset(asset) + .WithSource(); + + var buildCommand = new BuildCommand(testAsset); + buildCommand.Execute().Should().Pass(); + + using (var depsJsonFileStream = File.OpenRead(Path.Combine(buildCommand.GetOutputDirectory(targetFramework).FullName, exeName + ".deps.json"))) + { + var dependencyContext = new DependencyContextJsonReader().Read(depsJsonFileStream); + if (asset.Equals("DesktopReferencingNetStandardLibrary")) + { + dependencyContext.CompileLibraries.Any(l => l.Name.Equals("Library")).Should().BeTrue(); + } + else + { + dependencyContext.CompileLibraries.Any(l => l.Name.Equals("Microsoft.AspNetCore.App")).Should().BeFalse(); + } + } + } + [WindowsOnlyFact] public void It_resolves_assembly_conflicts_with_a_NETFramework_library() { From 4b761c750242b5d973830f6edbdd519d868d88fd Mon Sep 17 00:00:00 2001 From: Forgind <12969783+Forgind@users.noreply.github.com> Date: Fri, 6 Dec 2024 08:48:43 -0500 Subject: [PATCH 13/17] Add check --- .../CommandResolution/CompositeCommandResolver.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Cli/dotnet/CommandFactory/CommandResolution/CompositeCommandResolver.cs b/src/Cli/dotnet/CommandFactory/CommandResolution/CompositeCommandResolver.cs index 8aea52d488c7..8c15a17be927 100644 --- a/src/Cli/dotnet/CommandFactory/CommandResolution/CompositeCommandResolver.cs +++ b/src/Cli/dotnet/CommandFactory/CommandResolution/CompositeCommandResolver.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using Microsoft.DotNet.Cli.Utils; + namespace Microsoft.DotNet.CommandFactory { public class CompositeCommandResolver : ICommandResolver @@ -33,6 +35,7 @@ public CommandSpec Resolve(CommandResolverArguments commandResolverArguments) if (commandSpec != null) { + TelemetryEventEntry.SendFiltered(Tuple.Create(commandResolverArguments.CommandName.GetHashCode(), commandResolver.GetType())); return commandSpec; } } From 7ea5f4b01e55a16f90c952669493027f1323caf6 Mon Sep 17 00:00:00 2001 From: Forgind <12969783+Forgind@users.noreply.github.com> Date: Fri, 6 Dec 2024 09:49:18 -0500 Subject: [PATCH 14/17] Add structure --- .../CommandResolution/CompositeCommandResolver.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Cli/dotnet/CommandFactory/CommandResolution/CompositeCommandResolver.cs b/src/Cli/dotnet/CommandFactory/CommandResolution/CompositeCommandResolver.cs index 8c15a17be927..e716884e2c4c 100644 --- a/src/Cli/dotnet/CommandFactory/CommandResolution/CompositeCommandResolver.cs +++ b/src/Cli/dotnet/CommandFactory/CommandResolution/CompositeCommandResolver.cs @@ -7,6 +7,7 @@ namespace Microsoft.DotNet.CommandFactory { public class CompositeCommandResolver : ICommandResolver { + private const string CommandResolveEvent = "dotnet/cli/commandresolution/commandresolved"; private IList _orderedCommandResolvers; public IEnumerable OrderedCommandResolvers @@ -35,7 +36,12 @@ public CommandSpec Resolve(CommandResolverArguments commandResolverArguments) if (commandSpec != null) { - TelemetryEventEntry.SendFiltered(Tuple.Create(commandResolverArguments.CommandName.GetHashCode(), commandResolver.GetType())); + TelemetryEventEntry.TrackEvent(CommandResolveEvent, new Dictionary() + { + { "commandName", commandResolverArguments.CommandName.GetHashCode().ToString() }, + { "commandResolver", commandResolver.GetType().ToString() } + }); + return commandSpec; } } From 47ab5e9ff66dc972c371c801c27089cd40aab129 Mon Sep 17 00:00:00 2001 From: Forgind <12969783+Forgind@users.noreply.github.com> Date: Fri, 6 Dec 2024 10:05:15 -0500 Subject: [PATCH 15/17] PR comments --- .../CommandResolution/CompositeCommandResolver.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Cli/dotnet/CommandFactory/CommandResolution/CompositeCommandResolver.cs b/src/Cli/dotnet/CommandFactory/CommandResolution/CompositeCommandResolver.cs index e716884e2c4c..bba9b9b09721 100644 --- a/src/Cli/dotnet/CommandFactory/CommandResolution/CompositeCommandResolver.cs +++ b/src/Cli/dotnet/CommandFactory/CommandResolution/CompositeCommandResolver.cs @@ -7,7 +7,7 @@ namespace Microsoft.DotNet.CommandFactory { public class CompositeCommandResolver : ICommandResolver { - private const string CommandResolveEvent = "dotnet/cli/commandresolution/commandresolved"; + private const string CommandResolveEvent = "commandresolution/commandresolved"; private IList _orderedCommandResolvers; public IEnumerable OrderedCommandResolvers @@ -38,7 +38,7 @@ public CommandSpec Resolve(CommandResolverArguments commandResolverArguments) { TelemetryEventEntry.TrackEvent(CommandResolveEvent, new Dictionary() { - { "commandName", commandResolverArguments.CommandName.GetHashCode().ToString() }, + { "commandName", Sha256Hasher.HashWithNormalizedCasing(commandResolverArguments.CommandName) }, { "commandResolver", commandResolver.GetType().ToString() } }); From 8e0572a1f2ccfdd2e59b182b40faf3ea59784cd9 Mon Sep 17 00:00:00 2001 From: Forgind <12969783+Forgind@users.noreply.github.com> Date: Mon, 9 Dec 2024 18:36:22 -0500 Subject: [PATCH 16/17] =?UTF-8?q?Prevent=20null=20ref=20in=20tests=20?= =?UTF-8?q?=F0=9F=98=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CommandResolution/CompositeCommandResolver.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cli/dotnet/CommandFactory/CommandResolution/CompositeCommandResolver.cs b/src/Cli/dotnet/CommandFactory/CommandResolution/CompositeCommandResolver.cs index bba9b9b09721..df5e1b8426db 100644 --- a/src/Cli/dotnet/CommandFactory/CommandResolution/CompositeCommandResolver.cs +++ b/src/Cli/dotnet/CommandFactory/CommandResolution/CompositeCommandResolver.cs @@ -38,7 +38,7 @@ public CommandSpec Resolve(CommandResolverArguments commandResolverArguments) { TelemetryEventEntry.TrackEvent(CommandResolveEvent, new Dictionary() { - { "commandName", Sha256Hasher.HashWithNormalizedCasing(commandResolverArguments.CommandName) }, + { "commandName", commandResolverArguments is null ? string.Empty : Sha256Hasher.HashWithNormalizedCasing(commandResolverArguments.CommandName) }, { "commandResolver", commandResolver.GetType().ToString() } }); From 449ccc04bceea773c5881f5395bb6e1001ae1cef Mon Sep 17 00:00:00 2001 From: Rikki Gibson Date: Tue, 10 Dec 2024 17:03:35 -0800 Subject: [PATCH 17/17] format: stop checking for dotnet cli version (#44958) --- .../Commands/FormatCommandCommon.cs | 26 ------------------- src/BuiltInTools/dotnet-format/Resources.resx | 3 --- .../dotnet-format/xlf/Resources.cs.xlf | 5 ---- .../dotnet-format/xlf/Resources.de.xlf | 5 ---- .../dotnet-format/xlf/Resources.es.xlf | 5 ---- .../dotnet-format/xlf/Resources.fr.xlf | 5 ---- .../dotnet-format/xlf/Resources.it.xlf | 5 ---- .../dotnet-format/xlf/Resources.ja.xlf | 5 ---- .../dotnet-format/xlf/Resources.ko.xlf | 5 ---- .../dotnet-format/xlf/Resources.pl.xlf | 5 ---- .../dotnet-format/xlf/Resources.pt-BR.xlf | 5 ---- .../dotnet-format/xlf/Resources.ru.xlf | 5 ---- .../dotnet-format/xlf/Resources.tr.xlf | 5 ---- .../dotnet-format/xlf/Resources.zh-Hans.xlf | 5 ---- .../dotnet-format/xlf/Resources.zh-Hant.xlf | 5 ---- 15 files changed, 94 deletions(-) diff --git a/src/BuiltInTools/dotnet-format/Commands/FormatCommandCommon.cs b/src/BuiltInTools/dotnet-format/Commands/FormatCommandCommon.cs index 20486f7baa0e..a801de15dfbf 100644 --- a/src/BuiltInTools/dotnet-format/Commands/FormatCommandCommon.cs +++ b/src/BuiltInTools/dotnet-format/Commands/FormatCommandCommon.cs @@ -15,7 +15,6 @@ internal static class FormatCommandCommon internal const int UnhandledExceptionExitCode = 1; internal const int CheckFailedExitCode = 2; internal const int UnableToLocateMSBuildExitCode = 3; - internal const int UnableToLocateDotNetCliExitCode = 4; private static string[] VerbosityLevels => new[] { "q", "quiet", "m", "minimal", "n", "normal", "d", "detailed", "diag", "diagnostic" }; private static string[] SeverityLevels => new[] { "info", "warn", "error" }; @@ -102,14 +101,6 @@ internal static async Task FormatAsync(FormatOptions formatOptions, ILogger var runtimeVersion = GetRuntimeVersion(); logger.LogDebug(Resources.The_dotnet_runtime_version_is_0, runtimeVersion); - if (!TryGetDotNetCliVersion(out var dotnetVersion)) - { - logger.LogError(Resources.Unable_to_locate_dotnet_CLI_Ensure_that_it_is_on_the_PATH); - return UnableToLocateDotNetCliExitCode; - } - - logger.LogTrace(Resources.The_dotnet_CLI_version_is_0, dotnetVersion); - if (!TryLoadMSBuild(out var msBuildPath)) { logger.LogError(Resources.Unable_to_locate_MSBuild_Ensure_the_NET_SDK_was_installed_with_the_official_installer); @@ -354,23 +345,6 @@ private static string EnsureTrailingSlash(string path) ?.InformationalVersion; } - internal static bool TryGetDotNetCliVersion([NotNullWhen(returnValue: true)] out string? dotnetVersion) - { - try - { - var processInfo = ProcessRunner.CreateProcess("dotnet", "--version", captureOutput: true, displayWindow: false); - var versionResult = processInfo.Result.GetAwaiter().GetResult(); - - dotnetVersion = versionResult.OutputLines[0].Trim(); - return true; - } - catch - { - dotnetVersion = null; - return false; - } - } - internal static bool TryLoadMSBuild([NotNullWhen(returnValue: true)] out string? msBuildPath) { try diff --git a/src/BuiltInTools/dotnet-format/Resources.resx b/src/BuiltInTools/dotnet-format/Resources.resx index 999aa66a5a2d..ec627d90ce53 100644 --- a/src/BuiltInTools/dotnet-format/Resources.resx +++ b/src/BuiltInTools/dotnet-format/Resources.resx @@ -225,9 +225,6 @@ Standard input markers ('/dev/stdin', '-') can only be used either with `--include` or `--exclude`, but not both. - - Unable to locate dotnet CLI. Ensure that it is on the PATH. - The dotnet CLI version is '{0}'. diff --git a/src/BuiltInTools/dotnet-format/xlf/Resources.cs.xlf b/src/BuiltInTools/dotnet-format/xlf/Resources.cs.xlf index f86d04054ce8..f3a21d499b4d 100644 --- a/src/BuiltInTools/dotnet-format/xlf/Resources.cs.xlf +++ b/src/BuiltInTools/dotnet-format/xlf/Resources.cs.xlf @@ -377,11 +377,6 @@ Nepovedlo se najít MSBuild. Ujistěte se, že se sada .NET SDK nainstalovala pomocí oficiálního instalačního programu. - - Unable to locate dotnet CLI. Ensure that it is on the PATH. - Nepovedlo se najít .NET CLI. Ujistěte se, že se nachází v proměnné PATH. - - Unable to organize imports for '{0}'. The document is too complex. Nepovedlo se uspořádat importy pro {0}. Dokument je příliš složitý. diff --git a/src/BuiltInTools/dotnet-format/xlf/Resources.de.xlf b/src/BuiltInTools/dotnet-format/xlf/Resources.de.xlf index 677400e07673..40a49347e259 100644 --- a/src/BuiltInTools/dotnet-format/xlf/Resources.de.xlf +++ b/src/BuiltInTools/dotnet-format/xlf/Resources.de.xlf @@ -377,11 +377,6 @@ MSBuild wurde nicht gefunden. Stellen Sie sicher, dass das .NET SDK mit dem offiziellen Installationsprogramm installiert wurde. - - Unable to locate dotnet CLI. Ensure that it is on the PATH. - Die dotnet-CLI wurde nicht gefunden. Stellen Sie sicher, dass sie sich im Pfad befindet. - - Unable to organize imports for '{0}'. The document is too complex. Importe für "{0}" können nicht organisiert werden. Das Dokument ist zu komplex. diff --git a/src/BuiltInTools/dotnet-format/xlf/Resources.es.xlf b/src/BuiltInTools/dotnet-format/xlf/Resources.es.xlf index 79008550cfdd..775cdef7cdf3 100644 --- a/src/BuiltInTools/dotnet-format/xlf/Resources.es.xlf +++ b/src/BuiltInTools/dotnet-format/xlf/Resources.es.xlf @@ -377,11 +377,6 @@ No se encuentra MSBuild. Asegúrese de que el SDK de .NET se haya instalado con el instalador oficial. - - Unable to locate dotnet CLI. Ensure that it is on the PATH. - No se encuentra la CLI de dotnet. Asegúrese de que esté en la ruta de acceso (PATH). - - Unable to organize imports for '{0}'. The document is too complex. No se pueden organizar las importaciones para "{0}". El documento es demasiado complejo. diff --git a/src/BuiltInTools/dotnet-format/xlf/Resources.fr.xlf b/src/BuiltInTools/dotnet-format/xlf/Resources.fr.xlf index 7115ef2dd68a..c29da3ec3b44 100644 --- a/src/BuiltInTools/dotnet-format/xlf/Resources.fr.xlf +++ b/src/BuiltInTools/dotnet-format/xlf/Resources.fr.xlf @@ -377,11 +377,6 @@ Impossible de localiser MSBuild. Vérifiez que le SDK .NET a été installé avec le programme d'installation officiel. - - Unable to locate dotnet CLI. Ensure that it is on the PATH. - Impossible de localiser l'interface CLI dotnet. Vérifiez qu'elle est dans le chemin. - - Unable to organize imports for '{0}'. The document is too complex. Impossible d'organiser les importations pour '{0}'. Le document est trop complexe. diff --git a/src/BuiltInTools/dotnet-format/xlf/Resources.it.xlf b/src/BuiltInTools/dotnet-format/xlf/Resources.it.xlf index 3ffa3a39380f..2aeb29336f18 100644 --- a/src/BuiltInTools/dotnet-format/xlf/Resources.it.xlf +++ b/src/BuiltInTools/dotnet-format/xlf/Resources.it.xlf @@ -377,11 +377,6 @@ Non è possibile individuare MSBuild. Assicurarsi che .NET SDK sia stato installato con il programma di installazione ufficiale. - - Unable to locate dotnet CLI. Ensure that it is on the PATH. - Non è possibile individuare l'interfaccia della riga di comando di dotnet. Assicurarsi che sia indicata in PATH. - - Unable to organize imports for '{0}'. The document is too complex. Non è possibile organizzare le importazioni per '{0}'. Il documento è troppo complesso. diff --git a/src/BuiltInTools/dotnet-format/xlf/Resources.ja.xlf b/src/BuiltInTools/dotnet-format/xlf/Resources.ja.xlf index 11fa905930d7..4cf225955ceb 100644 --- a/src/BuiltInTools/dotnet-format/xlf/Resources.ja.xlf +++ b/src/BuiltInTools/dotnet-format/xlf/Resources.ja.xlf @@ -377,11 +377,6 @@ MSBuild が見つかりません。.NET SDK が正式なインストーラーでインストールされたことを確認してください。 - - Unable to locate dotnet CLI. Ensure that it is on the PATH. - dotnet CLI が見つかりません。PATH 上にあることを確認してください。 - - Unable to organize imports for '{0}'. The document is too complex. '{0}' のインポートを整理できません。ドキュメントが複雑すぎます。 diff --git a/src/BuiltInTools/dotnet-format/xlf/Resources.ko.xlf b/src/BuiltInTools/dotnet-format/xlf/Resources.ko.xlf index e8d31acc2adb..5fe1286052e1 100644 --- a/src/BuiltInTools/dotnet-format/xlf/Resources.ko.xlf +++ b/src/BuiltInTools/dotnet-format/xlf/Resources.ko.xlf @@ -377,11 +377,6 @@ MSBuild를 찾을 수 없습니다. 공식 설치 관리자를 사용하여 .NET SDK를 설치했는지 확인하세요. - - Unable to locate dotnet CLI. Ensure that it is on the PATH. - dotnet CLI를 찾을 수 없습니다. PATH에 있는지 확인하세요. - - Unable to organize imports for '{0}'. The document is too complex. '{0}'에 대한 가져오기를 구성할 수 없습니다. 문서가 너무 복잡합니다. diff --git a/src/BuiltInTools/dotnet-format/xlf/Resources.pl.xlf b/src/BuiltInTools/dotnet-format/xlf/Resources.pl.xlf index 936d356f2ac0..37b8a4e1f484 100644 --- a/src/BuiltInTools/dotnet-format/xlf/Resources.pl.xlf +++ b/src/BuiltInTools/dotnet-format/xlf/Resources.pl.xlf @@ -377,11 +377,6 @@ Nie można zlokalizować programu MSBuild. Upewnij się, że zestaw .NET SDK został zainstalowany przy użyciu oficjalnego instalatora. - - Unable to locate dotnet CLI. Ensure that it is on the PATH. - Nie można zlokalizować wiersza polecenia dotnet. Upewnij się, że znajduje się on w ścieżce. - - Unable to organize imports for '{0}'. The document is too complex. Nie można zorganizować importów dla elementu „{0}”. Dokument jest zbyt złożony. diff --git a/src/BuiltInTools/dotnet-format/xlf/Resources.pt-BR.xlf b/src/BuiltInTools/dotnet-format/xlf/Resources.pt-BR.xlf index 8061e736ecbe..b57c3e3b44f4 100644 --- a/src/BuiltInTools/dotnet-format/xlf/Resources.pt-BR.xlf +++ b/src/BuiltInTools/dotnet-format/xlf/Resources.pt-BR.xlf @@ -377,11 +377,6 @@ Não é possível localizar o MSBuild. Verifique se o SDK do .NET foi instalado com o instalador oficial. - - Unable to locate dotnet CLI. Ensure that it is on the PATH. - Não é possível localizar a CLI do dotnet. Verifique se está no CAMINHO. - - Unable to organize imports for '{0}'. The document is too complex. Não é possível organizar importações para '{0}'. O documento é muito complexo. diff --git a/src/BuiltInTools/dotnet-format/xlf/Resources.ru.xlf b/src/BuiltInTools/dotnet-format/xlf/Resources.ru.xlf index 738cdc715ecd..876497b11b1e 100644 --- a/src/BuiltInTools/dotnet-format/xlf/Resources.ru.xlf +++ b/src/BuiltInTools/dotnet-format/xlf/Resources.ru.xlf @@ -377,11 +377,6 @@ Не удается найти MSBuild. Убедитесь, что пакет SDK для .NET был установлен с официальным установщиком. - - Unable to locate dotnet CLI. Ensure that it is on the PATH. - Не удалось найти CLI dotnet. Убедитесь, что путь к нему добавлен в переменную среды PATH. - - Unable to organize imports for '{0}'. The document is too complex. Не удается организовать импорты для "{0}". Слишком сложный документ. diff --git a/src/BuiltInTools/dotnet-format/xlf/Resources.tr.xlf b/src/BuiltInTools/dotnet-format/xlf/Resources.tr.xlf index a2e299a0719d..c20259208904 100644 --- a/src/BuiltInTools/dotnet-format/xlf/Resources.tr.xlf +++ b/src/BuiltInTools/dotnet-format/xlf/Resources.tr.xlf @@ -377,11 +377,6 @@ MSBuild bulunamıyor. .NET SDK'nın resmi yükleyici kullanılarak yüklendiğinden emin olun. - - Unable to locate dotnet CLI. Ensure that it is on the PATH. - dotnet CLI bulunamıyor. dotnet CLI'nin PATH üzerinde olduğundan emin olun. - - Unable to organize imports for '{0}'. The document is too complex. '{0}' için içeri aktarmalar düzenlenemiyor. Belge çok karmaşık. diff --git a/src/BuiltInTools/dotnet-format/xlf/Resources.zh-Hans.xlf b/src/BuiltInTools/dotnet-format/xlf/Resources.zh-Hans.xlf index 2159fb65a4d1..88482781e59c 100644 --- a/src/BuiltInTools/dotnet-format/xlf/Resources.zh-Hans.xlf +++ b/src/BuiltInTools/dotnet-format/xlf/Resources.zh-Hans.xlf @@ -377,11 +377,6 @@ 无法找到 MSBuild。请确保 .NET SDK 是与官方安装程序一起安装的。 - - Unable to locate dotnet CLI. Ensure that it is on the PATH. - 找不到 dotnet CLI。请确保它在路径上。 - - Unable to organize imports for '{0}'. The document is too complex. 无法整理“{0}”的导入项。文档太复杂。 diff --git a/src/BuiltInTools/dotnet-format/xlf/Resources.zh-Hant.xlf b/src/BuiltInTools/dotnet-format/xlf/Resources.zh-Hant.xlf index 68ef3223f390..10d7cfa16699 100644 --- a/src/BuiltInTools/dotnet-format/xlf/Resources.zh-Hant.xlf +++ b/src/BuiltInTools/dotnet-format/xlf/Resources.zh-Hant.xlf @@ -377,11 +377,6 @@ 找不到 MSBuild。請確認已使用正式安裝程式安裝了 .NET SDK。 - - Unable to locate dotnet CLI. Ensure that it is on the PATH. - 找不到 dotnet CLI。請確認其位於 PATH 上。 - - Unable to organize imports for '{0}'. The document is too complex. 無法組織 '{0}' 的匯入。文件太複雜。