如何在.NET交互式笔记本中包括项目参考?

发布于 2025-01-22 05:28:25 字数 524 浏览 1 评论 0原文

使用NET 6 i具有以下项目结构:

nuget.config
project.code-workspace
- Core
  Core.csproj
- Api
  Api.csproj
- Sim
  notebook.ipynb

where Notebook.ipynb现在仅是:

#i "nuget:https://api.nuget.org/v3/index.json"

#r "nuget:Microsoft.Data.Analysis,0.*"

using System;
using Microsoft.Data.Analysis;

Console.WriteLine("Hello World!");

如何在Note> Notebook.ipynb中包含对Core和API Projects的项目引用?

我需要在Notebook.ipynb中使用一些核心和API项目类。

Using NET 6 I have the following project structure:

nuget.config
project.code-workspace
- Core
  Core.csproj
- Api
  Api.csproj
- Sim
  notebook.ipynb

Where notebook.ipynb is for now just:

#i "nuget:https://api.nuget.org/v3/index.json"

#r "nuget:Microsoft.Data.Analysis,0.*"

using System;
using Microsoft.Data.Analysis;

Console.WriteLine("Hello World!");

How to include a project reference to Core and Api projects in notebook.ipynb?

I need to use some of the Core and Api project classes in notebook.ipynb.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧人哭 2025-01-29 05:28:25

目前,这是不受欢迎的。参见 this 问题。我尝试使用dotnet pack并从本地文件夹安装创建的软件包,但失败了。我唯一设法完成工作的是构建解决方案并手动添加.dll:

假设下一个解决方案结构:

connect_solution.ipynb
- ClassLib\ClassLib.csproj (contains SomeDep.cs)
- Api\Api.csproj (references ClassLib.csproj, contains WeatherForecast)
#!pwsh 
dotnet build .\Api\Api.csproj --verbosity quiet
#r ".\Api\bin\Debug\net6.0\Api.dll"
using ClassLib;
using Api;
new SomeDep().Display();
new WeatherForecast()

Currently that is not supported out of the box. See this issue. I've tried to use dotnet pack and install created package from local folder but failed. The only I've managed to make work is to build solution and add .dll manually:

Assuming next solution structure:

connect_solution.ipynb
- ClassLib\ClassLib.csproj (contains SomeDep.cs)
- Api\Api.csproj (references ClassLib.csproj, contains WeatherForecast)
#!pwsh 
dotnet build .\Api\Api.csproj --verbosity quiet
#r ".\Api\bin\Debug\net6.0\Api.dll"
using ClassLib;
using Api;
new SomeDep().Display();
new WeatherForecast()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文