Giter VIP home page Giter VIP logo

Comments (8)

oleg-shilo avatar oleg-shilo commented on August 15, 2024

I don't have .NET Core handy so I cannot test. But this is what you can do to resolve the problem.

The NuGet CS-Script.bin package content is grouped by CLR version. And placed in the individual folders of the CLR TargetVersion of your VS project. Tough I am not sure how .NET Core VSCode does it.

The problem is most likely caused by the assemblies being referenced from the package folder that does not contain Microsoft.CodeAnalysis.CSharp.dll (e.g. packages\CS-Script.bin.3.18.1.0\lib\net45).

If you ensure that you reference assemblies from the folder with the full set of dependencies (e.g. packages\CS-Script.bin.3.18.1.0\lib\net46) then most likely the problem will go away.

Alternatively you may completely avoid Microsoft.CodeAnalysis dependency if you do not use Roslyn at all. See if setting the engine to Mono or CodeDom get you through:

CSScript.EvaluatorConfig.Engine = EvaluatorEngine.Mono;
//or 
CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom;

Let me know if it hepled.

from cs-script.

nike61 avatar nike61 commented on August 15, 2024

It seems that ASP Core needs Microsoft.CodeAnalysis.CSharp version >= 1.3.0. But cs-script uses 1.2.0 version. I can't downgrade ASP Core to use 1.2.0 because I'm getting following error:

Microsoft.AspNetCore.Mvc (>= 1.0.0) -> Microsoft.AspNetCore.Mvc.Razor (>= 1.0.0) -> Microsoft.CodeAnalysis.CSharp (>= 1.3.0)
Microsoft.CodeAnalysis.CSharp.Scripting (>= 1.2.0) -> Microsoft.CodeAnalysis.CSharp (= 1.2.0).

That also didn't helped:
CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom;

Can I somehow make cs-script use 1.3.0 version?

Thank you for help!

from cs-script.

oleg-shilo avatar oleg-shilo commented on August 15, 2024

OK, I think there is some misunderstanding here. CS-Script is not build for Roslyn 1.2 It will use whatever Roslyn is available at runtime. Thus recompiling it will not change anything.

I asked you to set the engine to CodeDom because I wanted CS-Script not to use Roslyn at all and load ICodeCompiler instead. ICodeCompiler is normally a part of any .NET runtime. I cannot understand from your short description what is the problem but I do trust you it didn't work. Most likely because .NET Core doesn't implement this interface.

I also asked you to try to set the engine to Mono because I wanted CS-Script not to use Roslyn and load Mono.CSharp.Evaluator instead. Mono.CSharp.Evaluator is a single no dependency assembly , which is distributed with CS-Script. Though I have no feedback on that yet.

If you really want to (or have to) use Roslyn you can just bring a single CSScriptLibrary.dll into your project and use it with any compatible version of Roslyn. Roslyn v1.3.2 seems OK.
Just to make it simpler and not to deal with many conflicting Roslyn binaries from various packages I have created a single "raw" NuGet package CS-Script.lib, which only delivers CS-Script and no other dependencies.

I have described this very same topic here: https://github.com/oleg-shilo/cs-script/wiki/Using-custom-version-of-Roslyn. It describes what exact Roslin assemblies you will need. The techniques was tested with CS-Script v3.18.1.0 and Roslyn v1.3.2 in a Console application project.

The fact that you your environment does not complain about CSScriptLibrary.dll means that the assembly is most likely compatible with .NET Core runtime and solving the problem is only a matter of removing unwanted Roslin binaries and replacing them with the correct ones.

from cs-script.

nike61 avatar nike61 commented on August 15, 2024

The CS-Script.lib saved my life. Thank you!

from cs-script.

oleg-shilo avatar oleg-shilo commented on August 15, 2024

The CS-Script.lib saved my life. Thank you!

Don't forget to name your firstborn "Oleg" :) :)

And on a serious note. Can I consider your feedback as a confirmation that that ASP.NET as an environment is compatible with CS-Script infrastructure?

from cs-script.

nike61 avatar nike61 commented on August 15, 2024

:) Yes it works, but I use Asp Core with .NET Full Framework, not .NET Core. So I use the following configuration in ASP Core:

"frameworks": {
    "net461": {
    }
}

from cs-script.

oleg-shilo avatar oleg-shilo commented on August 15, 2024

Great. Thank you.
I'll need to find time to test it against .NET Core

from cs-script.

oleg-shilo avatar oleg-shilo commented on August 15, 2024

Please see my extended test report in this therad #18

from cs-script.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.