从Visual Studio代码添加对另一个项目的引用 [英] Adding reference to another project from visual studio code
问题描述
如果一个库(例如,在github上)没有通过nuget包分发自身,我将不得不手动将其作为参考,对吗?我看到了很多有关如何为Visual Studio项目添加引用的参考文章,但是我似乎无法弄清楚如何在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.
在这种情况下,我已经下载了库的zip文件,并将扩展的文件夹移到了我的项目中,然后尝试使用< namespace>
进行了操作,
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.
我注意到下载的zip文件包含一个 .nuspec
.我可以使用该文件扩展名将其导入到我的项目中吗?
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?
推荐答案
假设您有两个项目:
1)Project1.Api
1) Project1.Api
2)Project2.Executable
2) Project2.Executable
cd Project2.Executable
dotnet add reference ../Project1.Api/Project1.Api.csproj
如果您检查Project2.Executable.csproj文件,您将看到以下条目:
If you check the Project2.Executable.csproj file, you will see the following entry:
<ItemGroup>
<ProjectReference Include = "..\Project1.Api\Project1.Api.csproj" />
</ItemGroup>
这篇关于从Visual Studio代码添加对另一个项目的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!