Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding reference to another project from visual studio code

If a library (eg, on github) doesn't distribute itself via a nuget package, I'd have to manually include it as a reference, correct? I see a lot of reference posts for how to add a reference to a project for Visual Studio, but I can't seem to figure out how to do it on Visual Studio Code.

In this case, I've downloaded the library's zip, and moved the expanded folder into my project, and then tried using <namespace>, which did not work.

EDIT:

I noticed that this downloaded zip contained a .nuspec. Is there something I can do with this file extension to import it in my project?

like image 430
user6728767 Avatar asked Apr 12 '18 20:04

user6728767


People also ask

How do I add a reference to a shared project?

You add references to a shared project just as you would a normal project reference. In Visual Studio or Fire, you right-click the "References" node of the real project and choose "Add Reference", and then pick the shared project from the list.

How do I add a reference path in Visual Studio?

If you're using Visual Basic, select the References page, and then click the Reference Paths button. In the Reference Paths dialog box, type the path of the folder that contains the item you want to reference in the Folder field, and then click the Add Folder button.

How do I add one project to another in Visual Studio?

Add a second project From the right-click or context menu of Solution 'QuickSolution' in Solution Explorer, select Add > New Project. In the Add a new project dialog box, enter the text unit test into the search box at the top, and then select C# under Language.


Video Answer


2 Answers

Let's say you have two projects:

1) Project1.Api

2) Project2.Executable


Command line syntax for dotnet add reference:

    cd Project2.Executable
    dotnet add reference ../Project1.Api/Project1.Api.csproj

If you check the Project2.Executable.csproj file, you will see the following entry:

    <ItemGroup>
         <ProjectReference Include = "..\Project1.Api\Project1.Api.csproj" />
    </ItemGroup>
like image 117
José Amílcar Casimiro Avatar answered Oct 18 '22 03:10

José Amílcar Casimiro


Add "vscode-solution-explorer" Extension. It will folder structure as visual studio. Right click on project --> Add Reference --> Select the reference project from the list.

like image 16
Avinash T H Avatar answered Oct 18 '22 02:10

Avinash T H