Is it possible to use code from a web project in C # Interactive?

I would like to use C # Interactive in Visual Studio 2017 to run some methods in classes in the .NET Framework 4.6.1 that I created that uses ASP.NET Core. In a traditional class library project, I can right-click on the project and select “Initialize Project Interaction” to use the classes from my project in the C # interactive window.

Right-clicking on my ASP.NET Core project, I do not have this option. Is there a way to use the classes from this project in C # Interactive?

If that matters, the classes that I would like to use in C # Interactive do not directly interact with ASP.NET Core; they are just data containers with methods. It might be possible to transfer them to a separate class library project in the solution, but I would like to know if it is possible to save them in an ASP.NET Core project.

My .csproj:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net461</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Folder Include="wwwroot\" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="EntityFramework" Version="6.1.3" />
    <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
    <PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.3" />
    <PackageReference Include="Microsoft.AspNet.Razor" Version="3.2.3" />
    <PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.0.0" />
    <PackageReference Include="RazorEngine" Version="3.10.0" />
  </ItemGroup>

</Project>
+4
source share
1 answer

Just open the C # dialog and type

#r "full path to dll\exe with your asp.net core project"

Then you can use your classes as usual.

, .NET Core - , ( ), , , # interactive .NET Framework. .NET(<TargetFramework>net461</TargetFramework>), .

+4

Source: https://habr.com/ru/post/1689741/


All Articles