Skip to content

Don't create tool manifests in a .config subfolder by default #50242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 14, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 13, 2025

This change removes the automatic creation of .config subdirectories when creating new tool manifests. Previously, when using dotnet tool install --create-manifest-if-needed or similar commands, the CLI would create manifests at .config/dotnet-tools.json. Now, manifests are created directly as dotnet-tools.json in the target directory.

Changes Made

  • ToolManifestFinder.cs: Updated WriteManifestFile() method to create manifests directly in the target folder instead of in a .config subdirectory
  • Template: Moved the tool manifest template from .config/dotnet-tools.json to dotnet-tools.json
  • Tests: Updated test expectations to reflect the new creation behavior while maintaining backward compatibility validation
  • Integration tests: Updated approval test expectations

Backward Compatibility

The change maintains full backward compatibility for reading existing manifests:

  • Existing .config/dotnet-tools.json files continue to be discovered and used
  • The search order still checks both .config/dotnet-tools.json and dotnet-tools.json locations
  • Only the creation logic has changed, not the discovery logic

This simplifies the local tools experience by reducing directory clutter while preserving support for existing projects.

Fixes #49296.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Don't create tool manifests in a .config subfolder by default Don't create tool manifests in a .config subfolder by default Aug 13, 2025
Copilot finished work on behalf of dsplaisted August 13, 2025 11:34
@Copilot Copilot AI requested a review from dsplaisted August 13, 2025 11:34
@dsplaisted
Copy link
Member

@copilot What about the tests for the consumption of the tools manifest file? Do they use the .config subfolder or not? Probably most of them should be changed to not use the .config folder, but we should still have some coverage of the .config folder to ensure backwards compatibility.

Copy link
Contributor Author

Copilot AI commented Aug 13, 2025

@copilot What about the tests for the consumption of the tools manifest file? Do they use the .config subfolder or not? Probably most of them should be changed to not use the .config folder, but we ...

I've analyzed the test coverage and made the necessary updates. Most consumption tests already use the direct path format (not .config), which is good. The main issues were:

  1. TemplateDiscoveryTool.cs was still looking for .config\dotnet-tools.json but dotnet new tool-manifest now creates dotnet-tools.json directly - fixed this
  2. Added backward compatibility test in ToolInstallLocalCommandTests to ensure tools can still be installed into existing .config manifests

Current test coverage:

  • Backward compatibility: ToolManifestFinderTests has specific tests for .config discovery + new install test
  • New behavior: Most consumption tests (Install/Update/Run/Restore) already use direct paths
  • Integration: Fixed template discovery test to match new creation behavior

The distribution is now appropriate - most tests use the new direct format while maintaining coverage for .config backward compatibility.

Commit: 5c42f9d

Copilot finished work on behalf of dsplaisted August 13, 2025 13:40
@@ -315,6 +315,26 @@ out ToolCommand restoredCommand
"But restore do not need to 'revert' since it just set in nuget global directory");
}

[Fact]
public void WhenRunWithExistingManifestInConfigDirectoryItShouldAddToExistingManifest()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot This test looks good, but can you add additional checks to it to verify that the manifest under the .config folder has been updated, and that no manifest exists in the root folder after the install command is run?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the requested checks to the test. The enhanced test now verifies:

  1. ✅ The manifest under the .config folder has been updated (checks file exists, contains the tool, and content differs from original)
  2. ✅ No manifest exists in the root folder after the install command runs

All ToolInstallLocalCommandTests continue to pass, ensuring backward compatibility is maintained.

Commit: 9099124

@Copilot Copilot AI requested a review from dsplaisted August 13, 2025 17:35
Copilot finished work on behalf of dsplaisted August 13, 2025 17:35
@dsplaisted dsplaisted marked this pull request as ready for review August 14, 2025 01:56
@Copilot Copilot AI review requested due to automatic review settings August 14, 2025 01:56
@dsplaisted dsplaisted requested a review from a team as a code owner August 14, 2025 01:56
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR changes the default behavior for creating new tool manifests to avoid automatically creating .config subdirectories. Previously, dotnet tool install --create-manifest-if-needed would create manifests at .config/dotnet-tools.json, but now they are created directly as dotnet-tools.json in the target directory.

  • Simplified manifest creation by removing automatic .config directory creation
  • Updated tests to reflect new creation behavior while maintaining backward compatibility
  • Preserved discovery logic to support existing .config/dotnet-tools.json files

Reviewed Changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated no comments.

File Description
src/Cli/dotnet/ToolManifest/ToolManifestFinder.cs Updated WriteManifestFile() to create manifests directly in target folder
test/dotnet.Tests/ToolManifestTests/ToolManifestFinderTests.cs Added test to verify new manifests are created without .config directory
test/dotnet.Tests/CommandTests/Tool/Install/ToolInstallLocalCommandTests.cs Updated test expectations and added backward compatibility test
test/dotnet-new.IntegrationTests/TemplateDiscoveryTool.cs Updated test to expect manifest in root directory

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@dsplaisted dsplaisted requested a review from a team August 14, 2025 01:56
Co-authored-by: Jacques Eloff <[email protected]>
@dsplaisted dsplaisted merged commit ebbdab5 into main Aug 14, 2025
27 checks passed
@dsplaisted dsplaisted deleted the copilot/fix-49296 branch August 14, 2025 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't create tool manifests in a .config subfolder by default
3 participants