更新时间:2022-12-03 15:48:55
如果您的项目在同一解决方案中,那么可以,您可以使用Visual Studio UI添加引用(添加引用命令)。背景参考将作为NuGet包添加。
If your projects are in the same solution, then yes, you can add a reference using the Visual Studio UI ("Add reference" command). A background reference will be added as a NuGet package.
您可以通过在 .csproj中添加
文件:< ProjectReference>
部分来手动执行此操作。
Manually you can do this by adding <ProjectReference>
section to the .csproj
file:
<ProjectReference Include="..\ClassLibrary1\ClassLibrary1.csproj" />
否则,您应该将项目打包到NuGet包中(使用 dotnet pack 命令),然后将其添加为其他NuGet程序包。
如果您不使用任何公共NuGet来源,则可以主机您自己的NuGet提要。
Otherwise, you should pack your project into a NuGet package (use the dotnet pack command) and then add it as other NuGet packages. If you do not use any public NuGet sources, you can host your own NuGet feed.
您遇到下一个错误:
".NET Core projects only support referencing .NET framework assemblies in this release.
To reference other assemblies they need to be included in a NuGet package"
因为您正在尝试将.NET项目添加到.NET Core项目,反之亦然。请查看此问题以了解更多详细信息:
Because you are trying to add a .NET project to a .NET Core project or wise versa. Look into this issue for more details: