Skip to content

Update command for adding project reference#52478

Open
Sam-Davidson wants to merge 1 commit intodotnet:mainfrom
Sam-Davidson:patch-1
Open

Update command for adding project reference#52478
Sam-Davidson wants to merge 1 commit intodotnet:mainfrom
Sam-Davidson:patch-1

Conversation

@Sam-Davidson
Copy link

@Sam-Davidson Sam-Davidson commented Mar 20, 2026

The old "reference add" doesn't work in the current version. Switching it to "add reference" fixes the issue.

dotnet reference add is the current way, and dotnet add reference is the old way, yet only the old way works for me, mysteriously. See below.

Summary

Describe your changes here.

Fixes #Issue_Number (if available)


Internal previews

📄 File 🔗 Preview link
docs/core/testing/unit-testing-csharp-with-mstest.md Get started with C# and MSTest

The old "reference add" doesn't work in the current version. Switching it to "add reference" fixes the issue.
@dotnetrepoman dotnetrepoman bot added this to the March 2026 milestone Mar 20, 2026
@dotnet-policy-service dotnet-policy-service bot added dotnet-fundamentals/svc community-contribution Indicates PR is created by someone from the .NET community. labels Mar 20, 2026
Copy link
Member

@Youssef1313 Youssef1313 left a comment

Choose a reason for hiding this comment

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

The dotnet add reference is the old way. This was updated in #43917.

The documentation link earlier also notes that.

Copy link
Member

@Youssef1313 Youssef1313 left a comment

Choose a reason for hiding this comment

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

Previous comment was approve by mistake.

The old "reference add" doesn't work in the current version. Switching it to "add reference" fixes the issue.

Which version do you use?

cc @MiYanni

@MiYanni
Copy link
Member

MiYanni commented Mar 20, 2026

@Youssef1313 Per this PR, we've switched to the preference being dotnet noun verb. So, the preference is dotnet reference add, just as it is also dotnet package add. At this point, most commands follow something close to dotnet [category] [action] to state it more generally. And yes, not everything follows this convention, but we've not spend the effort to make a new paradigm with enforcement at this time.

@Sam-Davidson
Copy link
Author

Strange, I appear to be on the latest version. I don't know why only the old dotnet add reference worked for me and dotnet reference add did not work. Here's all my version info in case it helps anyone:

Microsoft Windows [Version 10.0.19045.6456]
(c) Microsoft Corporation. All rights reserved.

C:\Users\Davidson>dotnet --info
.NET SDK:
 Version:           10.0.201
 Commit:            4d3023de60
 Workload version:  10.0.200-manifests.121cc9e6
 MSBuild version:   18.3.0-release-26153-122+4d3023de6

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19045
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\10.0.201\

.NET workloads installed:
There are no installed workloads to display.
Configured to use workload sets when installing new manifests.
No workload sets are installed. Run "dotnet workload restore" to install a workload set.

Host:
  Version:      10.0.5
  Architecture: x64
  Commit:       a612c2a105

.NET SDKs installed:
  10.0.201 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 10.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 10.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 10.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

C:\Users\Davidson>dotnet --list-sdks
10.0.201 [C:\Program Files\dotnet\sdk]

C:\Users\Davidson>dotnet --list-runtimes
Microsoft.AspNetCore.App 10.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 10.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 10.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

@MiYanni
Copy link
Member

MiYanni commented Mar 20, 2026

@Sam-Davidson We have aliases that allow dotnet add reference for backwards compatibility, so that the change wasn't a breaking one. Though, I don't understand why dotnet reference add wouldn't work. Does dotnet reference --help work? Should show this:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Indicates PR is created by someone from the .NET community. dotnet-fundamentals/svc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants