Comments (8)
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.
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.
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.
The CS-Script.lib saved my life. Thank you!
from cs-script.
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.
:) 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.
Great. Thank you.
I'll need to find time to test it against .NET Core
from cs-script.
Please see my extended test report in this therad #18
from cs-script.
Related Issues (20)
- NET8: "Microsoft.CodeAnalysis.CSharp" has been changed to "Microsoft.CodeAnalysis.CSharp.Workspaces." HOT 2
- Memory exhaustion by dotnet.exe, vscode, (-vscode) HOT 5
- How to use a compiled code into a loaded method. HOT 5
- Error in Eval using a referenced assembly with unloading enabled. HOT 5
- Promote dotnet tool more prominently HOT 3
- Strongly-named assembly required HOT 2
- Repository links to wrong website HOT 1
- Error with extension methods using Roslyn HOT 4
- `CSScript.Evaluator.LoadCode` broken on net48 after cs-script 4.8.3 HOT 13
- DllImport how to use in script HOT 5
- Too deeply nested script executions lead to not found NuGet packages HOT 23
- Assembly not found exception HOT 6
- Precompiler functionality broken HOT 4
- How can behavior similar to Python's reloading be implemented? HOT 12
- .net7+pubish single file+Error CS0246 HOT 2
- DirectoryNotFoundException using dotnet tool install -g CS-Script HOT 3
- Unable to compile script using CodeDom on macos HOT 4
- Location of script file Unable to get correct results in hosted script HOT 3
- Execution with `dotnet` engine fails if the script has spaces in the name
- //css_ref vs -r:: HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cs-script.