GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - SuperJMN/ReferenceSwitcher

BranchesTags
Open more actions menu

Latest commit

 

History

32 Commits
32 Commits

Folders and files

NameName
Last commit message
Last commit date
ReferenceSwitcher.Tool.Tests
ReferenceSwitcher.Tool.Tests
 
 
ReferenceSwitcher.Tool
ReferenceSwitcher.Tool
 
 
.gitignore
.gitignore
 
 
AGENTS.md
AGENTS.md
 
 
DotnetReferenceSwitcher.sln
DotnetReferenceSwitcher.sln
 
 
GitVersion.yml
GitVersion.yml
 
 
README.md
README.md
 
 
azure-pipelines.yml
azure-pipelines.yml
 
 
deployer.yaml
deployer.yaml
 
 

Repository files navigation

ReferenceSwitcher

ReferenceSwitcher is a .NET command line tool that automates switching between PackageReference and ProjectReference entries inside solutions. It is intended to make it easy to switch between developing against local projects and consuming NuGet packages.

Installation

The tool is published as a .NET tool (see the .csproj configuration). You can build and install it locally with:

dotnet build
# Then install the tool locally from the produced package if desired

Usage

The tool exposes two main commands:

  • to-projects: replaces PackageReference entries with ProjectReference entries when matching projects are found on disk.
  • to-packages: replaces ProjectReference entries with PackageReference entries when matching packages are found.

Both commands share the same basic arguments:

reference-switcher <command> \
  --solution <path-to-sln-or-slnx> \
  --scan-directory <directory-to-scan> \
  [--add-projects-to-solution]
  • --solution (-s): path to the .sln or .slnx file that defines the starting projects.
  • --scan-directory (-d): directory that will be scanned recursively for .csproj files used to build the project index.
  • --add-projects-to-solution: when specified, the tool also updates the solution file to reflect the changes.

Behavior of --add-projects-to-solution

When --add-projects-to-solution is used, the behavior depends on the selected command:

to-projects

  • After switching PackageReference entries to ProjectReference, the tool tracks all projects discovered via matching PackageId values.
  • Any discovered project that is not already present in the solution is added as a new Project(...) entry in the .sln file.
  • The new projects also receive entries in the ProjectConfigurationPlatforms section so that they participate in the existing solution configurations (for example Debug|Any CPU and Release|Any CPU).
  • For .slnx files, missing projects are added as <Project Path="..." /> entries.

If --add-projects-to-solution is not specified, only the .csproj files are updated and the solution file is left untouched.

to-packages

  • After switching ProjectReference entries back to PackageReference, the tool looks for projects in the solution that are considered foreign and removes them from the .sln file.
  • A project is considered foreign if its .csproj path is outside a reference root:
    • First, the tool walks up from the solution directory until it finds a directory that contains a .git folder. That directory is used as the reference root.
    • If no Git repository is found, the parent directory of the solution file is used as the reference root instead.
  • Any project whose resolved absolute .csproj path is not under this reference root is treated as foreign.
  • For each foreign project, the corresponding Project(...) / EndProject block is removed from the solution file, and any lines in Global sections that reference the project GUID (such as ProjectConfigurationPlatforms or nested project mappings) are also removed.
  • For .slnx files, the corresponding <Project Path="..." /> entry is removed, and empty <Folder> elements left behind are cleaned up.

If --add-projects-to-solution is not specified, only the .csproj files are updated and the solution file is left untouched.

Notes

  • The tool relies on PackageId metadata (and related MSBuild properties) to match projects with NuGet packages.
  • When multiple projects share the same PackageId, a deterministic selection heuristic is used to pick one candidate, and a warning is written to stderr.

About

No description, website, or topics provided.

Resources

Readme
Activity

Stars

1 star

Watchers

0 watching

Forks

1 fork
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.