Skip to content

Commit fac0117

Browse files
committed
Address / remove TODOs
1 parent efcdd4a commit fac0117

9 files changed

+15
-25
lines changed

src/Cli/dotnet/ToolPackage/LocalToolsResolverCache.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ public void Save(
3333
{
3434
EnsureFileStorageExists();
3535

36-
// TODO: Save resolved package info here?
37-
3836
foreach (var distinctPackageIdAndRestoredCommandMap in restoredCommandMap.GroupBy(x => x.Key.PackageId))
3937
{
4038
PackageId distinctPackageId = distinctPackageIdAndRestoredCommandMap.Key;
@@ -189,6 +187,5 @@ private class CacheRow
189187
public string Name { get; set; }
190188
public string Runner { get; set; }
191189
public string PathToExecutable { get; set; }
192-
// TODO: Need resolved package info here
193190
}
194191
}

src/Cli/dotnet/ToolPackage/RestoredCommandIdentifier.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ internal class RestoredCommandIdentifier(
1919
string runtimeIdentifier,
2020
ToolCommandName commandName) : IEquatable<RestoredCommandIdentifier>
2121
{
22-
23-
// TODO: What is this class and how is it different from CacheRow? Does it need to have the resolved package information?
24-
2522
public PackageId PackageId { get; } = packageId;
2623
public NuGetVersion Version { get; } = version ?? throw new ArgumentException(nameof(version));
2724
public NuGetFramework TargetFramework { get; } = targetFramework ?? throw new ArgumentException(nameof(targetFramework));

src/Cli/dotnet/ToolPackage/ToolConfigurationDeserializer.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ public static ToolConfiguration Deserialize(string pathToXml, IFileSystem fileSy
5757
throw new ToolConfigurationException(CliStrings.ToolSettingsMoreThanOneCommand);
5858
}
5959

60-
// TODO: Should be an error if runner is empty and there aren't any RID-specific packages
6160
var runner = dotNetCliTool.Commands[0].Runner;
6261
if (!string.IsNullOrEmpty(runner) && runner != "dotnet" && runner != "executable")
6362
{
@@ -71,6 +70,16 @@ public static ToolConfiguration Deserialize(string pathToXml, IFileSystem fileSy
7170
var ridSpecificPackages = dotNetCliTool.RuntimeIdentifierPackages?.ToDictionary(p => p.RuntimeIdentifier, p => new PackageIdentity(p.Id, new NuGet.Versioning.NuGetVersion(p.Version)))
7271
.AsReadOnly();
7372

73+
// Also error out if there are no RID-specific packages and the runner is empty
74+
if (string.IsNullOrEmpty(runner) && !ridSpecificPackages.Any())
75+
{
76+
throw new ToolConfigurationException(
77+
string.Format(
78+
CliStrings.ToolSettingsUnsupportedRunner,
79+
dotNetCliTool.Commands[0].Name,
80+
dotNetCliTool.Commands[0].Runner));
81+
}
82+
7483
return new ToolConfiguration(
7584
dotNetCliTool.Commands[0].Name,
7685
dotNetCliTool.Commands[0].EntryPoint,

src/Cli/dotnet/ToolPackage/ToolPackageDownloader.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ protected override void CreateAssetFile(
177177
managedCriteria.Add(standardCriteria);
178178

179179
// Create asset file
180-
// TODO: What about DotnetToolRidPackage type?
180+
// Note that we know that the package type for the lock file is DotnetTool because we just set it to that.
181+
// This if statement is still here because this mirrors code in NuGet for restore so maybe it will be easier to keep in sync if need be
181182
if (lockFileLib.PackageType.Contains(PackageType.DotnetTool))
182183
{
183184
AddToolsAssets(conventions, lockFileLib, collection, managedCriteria);

src/Cli/dotnet/ToolPackage/ToolPackageDownloaderBase.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ internal abstract class ToolPackageDownloaderBase : IToolPackageDownloader
2828
{
2929
private readonly IToolPackageStore _toolPackageStore;
3030

31-
// The directory that the tool package is returned
32-
protected DirectoryPath _toolReturnPackageDirectory;
33-
34-
// The directory that the tool asset file is returned
35-
protected DirectoryPath _toolReturnJsonParentDirectory;
36-
3731
protected readonly IFileSystem _fileSystem;
3832

3933
// The directory that global tools first downloaded
@@ -68,7 +62,7 @@ protected ToolPackageDownloaderBase(
6862
_localToolDownloadDir = new DirectoryPath(SettingsUtility.GetGlobalPackagesFolder(settings));
6963
_currentWorkingDirectory = currentWorkingDirectory;
7064

71-
_localToolAssetDir = new DirectoryPath(_fileSystem.Directory.CreateTemporarySubdirectory()); // PathUtilities.CreateTempSubdirectory());
65+
_localToolAssetDir = new DirectoryPath(_fileSystem.Directory.CreateTemporarySubdirectory());
7266
_runtimeJsonPath = runtimeJsonPathForTests ?? Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "RuntimeIdentifierGraph.json");
7367
}
7468

src/Cli/dotnet/ToolPackage/ToolPackageStoreAndQuery.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@ public IEnumerable<IToolPackage> EnumeratePackageVersions(PackageId packageId)
8989

9090
foreach (var subdirectory in _fileSystem.Directory.EnumerateDirectories(packageRootDirectory.Value))
9191
{
92-
// TODO: How to handle redirected RID-specific packages?
93-
// Probably we can restore both priamry and RID-specific packages under the same versioned folder,
94-
// for example .dotnet\tools\.store\microsoft.dotnet-interactive\1.0.415202
95-
// Probably the RID-specific package assets file can be stored under a different name, such as project.assets.<RID>.json
9692
yield return new ToolPackageInstance(id: packageId,
9793
version: NuGetVersion.Parse(Path.GetFileName(subdirectory)),
9894
packageDirectory: new DirectoryPath(subdirectory),

src/Tasks/Microsoft.NET.Build.Tasks/GenerateToolsSettingsFile.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ namespace Microsoft.NET.Build.Tasks
99
{
1010
public class GenerateToolsSettingsFile : TaskBase
1111
{
12-
// bump whenever the format changes such that it will break old consumers
13-
// TODO: Make this version 2 when tool has RID-specific packages?
14-
//private static readonly int _formatVersion = 1;
15-
1612
[Required]
1713
public string EntryPointRelativePath { get; set; }
1814

@@ -41,6 +37,7 @@ protected override void ExecuteCore()
4137
internal static XDocument GenerateDocument(string entryPointRelativePath, string commandName, string commandRunner, string runtimeIdentifier,
4238
string toolPackageId, string toolPackageVersion, ITaskItem[] toolPackageRuntimeIdentifiers)
4339
{
40+
// Format version should bump whenever the format changes such that it will break old consumers
4441
int formatVersion = 1;
4542

4643
if (string.IsNullOrEmpty(commandRunner))

src/Tasks/Microsoft.NET.Build.Tasks/RemoveTargetFromList.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class RemoveTargetFromList : TaskBase
2121
[Required]
2222
public string TargetToRemove { get; set; }
2323

24+
// Output needs to be an array so MSBuild won't escape semicolonns
2425
[Output]
2526
public string[] UpdatedTargetList { get; private set; }
2627

src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackTool.targets

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ Copyright (c) .NET Foundation. All rights reserved.
100100
<PackageId>$(PackageId).$(RuntimeIdentifier)</PackageId>
101101
</PropertyGroup>
102102

103-
<!-- TODO: Should we read Version from the corresponding ToolPackageRuntimeIdentifier item, if it's set? -->
104-
105103
</Target>
106104

107105
<Target Name="PackToolImplementation" Condition="'$(_ToolPackageShouldIncludeImplementation)' == 'true'">

0 commit comments

Comments
 (0)