aldo
aldo

Reputation: 111

C# in Visual Studio and Visual Studio Code

So I am new in C# and tried to load a project written in Visual Studio in Visual Studio Code. I'm curious as to why "references" option that was there in Solution Explorer in Visual Studio now gone in VSCode? Or maybe it is translated to something else in VSCode? Because now in VSCode I don't know how to add a reference for DemoLibrary.tests, for example, to DemoLibrary.

enter image description here

Upvotes: 3

Views: 957

Answers (2)

Lex Li
Lex Li

Reputation: 63203

Because VSCode opens the raw folder view for you, while Visual Studio instead shows the actual logical solution/project data structure suitable for .NET development.

You can try to open the folder in VS and you will get the same experience as VSCode.

All package pages on NuGet.org show various ways to add packages to your projects so many do work with VSCode.

For example, click the PackageReference tab on https://www.nuget.org/packages/Json.Net/ and it shows what element you should add to project files directly.

BTW, you should not use packages.config any more. The whole ecosystem is now around package references.

And you seem to download a very old sample (using .NET Framework), which will give you more pains due to breaking changes. Try to find fresh and new sample projects (like the ones on .NET Core) please.

Upvotes: 1

Marco
Marco

Reputation: 23937

All the references are stored in your DemoLibrary.Tests.csproj. You can edit them directly in there, or use the dotnet cli:

dotnet add DemoLibrary.Tests/DemoLibrary.Tests.csproj reference DemoLibrary/DemoLibrary.csproj

Alternative commands are remove and list. You can find the documentation and examples here:

https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-add-reference https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-list-reference https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-remove-reference

Please keep in mind, that VSCode is a text editor (on steroids), not a full fledged IDE - although it comes pretty close in some cases.

Upvotes: 2

Related Questions