Skip to content
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

Allow repo with only a dotnet-tools.json file #9411

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions nuget/lib/dependabot/nuget/file_fetcher.rb
Expand Up @@ -24,13 +24,14 @@ def self.required_files_in?(filenames)
return true if filenames.any? { |f| f.end_with?(".sln") }
return true if filenames.any? { |f| f.match?("^src$") }
return true if filenames.any? { |f| f.end_with?(".proj") }
return true if filenames.any? { |f| f.match?(/^dotnet\-tools\.json$/i) }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not being a ruby person, I'm not sure what the best way to refactor this to make the linter happy about the perceived complexity.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This change may allow the file_fetcher to run but it doesn't change how the updater works and it currently is expecting a project file to work against.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you point me at the rough area of code I need to go and touch? I started off by searching for the error message I got in the GitHub UI.

Copy link
Collaborator

Choose a reason for hiding this comment

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

May have to hold off for a bit as we are trying to move more of the updater logic from ruby to C# for the NuGet ecosystem. The new discover command in the NuGetUpdater.Core project is now responsible for parsing dependencies. It currently uses project files as its starting point but could be updated to simply look for global.json and .config/dotnet-tools.json in the target directory. The update command in NuGetUpdater.Core is responsible for performing the update and will be going through some changes this month.


filenames.any? { |name| name.match?(/\.(cs|vb|fs)proj$/) }
end

sig { override.returns(String) }
def self.required_files_message
"Repo must contain a .proj file, .(cs|vb|fs)proj file, or a packages.config."
"Repo must contain a .proj file, .(cs|vb|fs)proj file, a packages.config, or a dotnet-tools.json."
end

sig do
Expand Down Expand Up @@ -70,7 +71,7 @@ def fetch_files
Pathname.new(fetched_file.directory).join(fetched_file.name).cleanpath.to_path
end

if project_files.none? && packages_config_files.none?
if project_files.none? && packages_config_files.none? && dotnet_tools_json.nil?
raise T.must(@missing_sln_project_file_errors.first) if @missing_sln_project_file_errors&.any?

raise_dependency_file_not_found
Expand Down