Skip to content

Add nugetConfigPath parameter to support custom NuGet feeds in enterprise environments#1808

Merged
arturcic merged 6 commits intomainfrom
copilot/add-custom-nuget-config-support
Oct 31, 2025
Merged

Add nugetConfigPath parameter to support custom NuGet feeds in enterprise environments#1808
arturcic merged 6 commits intomainfrom
copilot/add-custom-nuget-config-support

Conversation

Copy link
Contributor

Copilot AI commented Oct 31, 2025

  • Add nugetConfigPath input to GitHub Actions setup (gitversion/setup/action.yml)
  • Add nugetConfigPath input to GitHub Actions setup (gitreleasemanager/setup/action.yml)
  • Add nugetConfigPath input to Azure DevOps task definition (dist/azure/gitversion/setup/task.json)
  • Add nugetConfigPath input to Azure DevOps task definition (dist/azure/gitreleasemanager/setup/task.json)
  • Update SetupSettings model to include nugetConfigPath field (src/tools/common/models.ts)
  • Update SettingsProvider.getSetupSettings() to read nugetConfigPath input (src/tools/common/settings.ts)
  • Update DotnetTool.installTool() to accept and use nugetConfigPath parameter (src/tools/common/dotnet-tool.ts)
  • Update DotnetTool.install() to pass nugetConfigPath to installTool (src/tools/common/dotnet-tool.ts)
  • Add tests for the new nugetConfigPath functionality
  • Build and verify changes
  • Add documentation with examples
  • Run code review - PASSED (no issues found)
  • Run security scan - PASSED (no vulnerabilities found)
  • Add nuget.config file in root directory
  • Update GitHub CI workflow to use nuget.config
  • Update Azure DevOps CI pipeline to use nuget.config
  • Make nugetConfigPath optional in SetupSettings type (addressed review feedback)
  • Remove unnecessary conversion of empty string to undefined (addressed review feedback)

Summary

Successfully implemented support for custom NuGet configuration files in the gitversion-setup and gitreleasemanager-setup actions/tasks. The implementation:

Minimal Changes: Only modified the necessary files to add the new parameter
Backward Compatible: Existing workflows will continue to work without modification
Well Tested: Added unit tests and all existing tests pass (except 8 pre-existing failures unrelated to this change)
Documented: Added usage examples for both GitHub Actions and Azure DevOps
Secure: Passed both code review and security scan with no issues
Consistent: Applied the same change to both GitVersion and GitReleaseManager tools
CI Integration: Added nuget.config and updated both GitHub and Azure DevOps CI pipelines to use it
Type Safe: Made nugetConfigPath properly optional in TypeScript type definitions
Clean Code: Removed unnecessary type conversions based on review feedback

Security Summary

No vulnerabilities were discovered during the security scan. The implementation safely passes user-provided configuration file paths to the dotnet tool install command using the standard --configfile argument.

Original prompt

This section details on the original issue you should resolve

<issue_title>[ISSUE]: Add support for specifying a custom nuget.config file for tool installation in gitversion-setup</issue_title>
<issue_description>### Prerequisites

  • I have written a descriptive issue title
  • I have searched issues to ensure it has not already been reported

GitVersion package

AzureDevops task

What are you seeing?

Currently, the gitversion-setup task installs the GitVersion .NET tool directly from nuget.org without a way to override the feed source.
As a result, the setup step fails in environments where outbound connections to public package feeds are blocked.

In our enterprise environments, self-hosted Azure DevOps agents are not allowed to connect to public feeds like nuget.org. Instead, private Azure Artifacts feeds or Artifactory feeds are used with upstream sources for internal dependency management.

What is expected?

Introduce a new optional input parameter to the gitversion-setup task:

  • task: gitversion-setup@4
    inputs:
    versionSpec: '6.4.x'
    nugetConfigPath: '$(Build.SourcesDirectory)/nuget.config'

Steps to Reproduce

Currently, the only workaround is to preinstall the GitVersion.Tool on all agents or to run a custom script which installs the tool.

Output log or link to your CI build (if appropriate).

```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>

💡 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 AI and others added 2 commits October 31, 2025 09:04
Co-authored-by: arturcic <1760506+arturcic@users.noreply.github.com>
Co-authored-by: arturcic <1760506+arturcic@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for custom nuget.config in gitversion-setup Add nugetConfigPath parameter to support custom NuGet feeds in enterprise environments Oct 31, 2025
Copilot AI requested a review from arturcic October 31, 2025 09:11
@arturcic
Copy link
Member

@copilot add a nuget.config file in root with this content

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
  </packageSources>
  <packageSourceMapping>
    <packageSource key="nuget.org">
      <package pattern="*" />
    </packageSource>
  </packageSourceMapping>
</configuration>

Update the ci github action and ci azure devops to use this file

Co-authored-by: arturcic <1760506+arturcic@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 31, 2025

@copilot add a nuget.config file in root with this content

<?xml version="1.0" encoding="utf-8"?>

...

Done. Added nuget.config in the root with the specified content and updated both CI workflows:

  • GitHub Actions: Added nugetConfigPath: '${{ github.workspace }}/nuget.config' to the gitversion/setup step
  • Azure DevOps: Added INPUT_NUGETCONFIGPATH variable and passed it to the setup action

Commit: 3b57358

@arturcic arturcic marked this pull request as ready for review October 31, 2025 11:43
@arturcic arturcic requested a review from Copilot October 31, 2025 11:43
Copy link

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 adds support for custom NuGet configuration files to the GitTools actions, allowing users to specify alternative package sources when installing GitVersion and GitReleaseManager tools. This is particularly useful in enterprise environments with restricted access to public NuGet feeds.

Key changes:

  • Added nugetConfigPath parameter to setup actions for both GitVersion and GitReleaseManager
  • Updated tool installation logic to use custom NuGet config when provided
  • Added documentation and examples demonstrating the new feature

Reviewed Changes

Copilot reviewed 14 out of 18 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/tools/common/models.ts Added nugetConfigPath property to SetupSettings type
src/tools/common/settings.ts Modified to retrieve nugetConfigPath input and include it in settings
src/tools/common/dotnet-tool.ts Updated installTool method to accept and use nugetConfigPath parameter
src/tests/tools/common/settings.spec.ts Added test case for nugetConfigPath setting
src/tests/tools/common/dotnet-tool.spec.ts Updated test fixture to include nugetConfigPath
gitversion/setup/action.yml Added nugetConfigPath input definition
gitreleasemanager/setup/action.yml Added nugetConfigPath input definition
docs/examples/github/gitversion/setup.md Added documentation and example usage
docs/examples/github/gitreleasemanager/setup.md Added documentation and example usage
docs/examples/azure/gitversion/setup.md Added documentation and example usage
docs/examples/azure/gitreleasemanager/setup.md Added documentation and example usage
nuget.config Added sample NuGet configuration file
dist/tools/libs/tools.mjs Compiled output reflecting TypeScript changes
dist/tools/libs/tools.mjs.map Source map reflecting TypeScript changes
dist/azure/gitversion/setup/task.json Added nugetConfigPath input for Azure task
dist/azure/gitreleasemanager/setup/task.json Added nugetConfigPath input for Azure task
.github/workflows/ci.yml Added example usage in CI workflow
.azure/ci.yml Added example usage in Azure CI pipeline

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: arturcic <1760506+arturcic@users.noreply.github.com>
Copy link

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

Copilot reviewed 13 out of 17 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

ignoreFailedSources,
preferLatestVersion
preferLatestVersion,
nugetConfigPath: nugetConfigPath || undefined
Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

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

The expression nugetConfigPath || undefined will convert an empty string to undefined, which may not be the intended behavior. If an empty string is a valid input (as suggested by the default value '' in action.yml files), this will incorrectly convert it to undefined. Consider using nullish coalescing (??) instead: nugetConfigPath: nugetConfigPath || undefined should be nugetConfigPath: nugetConfigPath ? nugetConfigPath : undefined or remove the conversion entirely if empty strings should be preserved.

Suggested change
nugetConfigPath: nugetConfigPath || undefined
nugetConfigPath: nugetConfigPath

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the || undefined conversion. The if (nugetConfigPath) check in dotnet-tool.ts already handles empty strings correctly (treats them as falsy), so the conversion was unnecessary.

Commit: a9ab30a

Co-authored-by: arturcic <1760506+arturcic@users.noreply.github.com>
@sonarqubecloud
Copy link

1 similar comment
@sonarqubecloud
Copy link

Copy link

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

Copilot reviewed 13 out of 17 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@arturcic arturcic requested a review from Copilot October 31, 2025 12:20
Copy link

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

Copilot reviewed 13 out of 17 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@arturcic arturcic removed their assignment Oct 31, 2025
@arturcic arturcic merged commit d5215ea into main Oct 31, 2025
34 checks passed
@arturcic arturcic deleted the copilot/add-custom-nuget-config-support branch October 31, 2025 12:27
@mergify
Copy link
Contributor

mergify bot commented Oct 31, 2025

Thank you @Copilot for your contribution!

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.

[ISSUE]: Add support for specifying a custom nuget.config file for tool installation in gitversion-setup

3 participants