Error 'Microsoft.CSharp' already has a dependency defined for 'System.Dynamic.Runtime'

6,276 views
Skip to first unread message

uwe....@gmail.com

unread,
Aug 11, 2016, 7:20:28 AM8/11/16
to CS-Script
I've recently updated to the latest version 3.14.0.0 of cs-script.

In my code, I'm doing:

//css_nuget -ng:"-Source https://nuget.org/api/v2/" Newtonsoft.Json

to include Newtonsoft.Json package.

Since recently I get the error:

C# Script execution engine. Version 3.14.0.0.
Copyright (C) 2004-2016 Oleg Shilo.

NuGet> Processing NuGet packages...
Attempting to resolve dependency 'Microsoft.CSharp (= 4.0.1)'.
'Microsoft.CSharp' already has a dependency defined for 'System.Dynamic.Runtime'.
Error: Specified file could not be compiled.

System.ApplicationException: Cannot process NuGet package 'Newtonsoft.Json'
   bei csscript.NuGet.Resolve(String[] packages, Boolean supressDownloading, String script)
   bei csscript.CSExecutor.AggregateReferencedAssemblies(ScriptParser parser)
   bei csscript.CSExecutor.Compile(String scriptFileName)
   bei csscript.CSExecutor.ExecuteImpl()

I only get rid of the error if I remove this line in my code:

//css_nuget -ng:"-Source https://nuget.org/api/v2/" Newtonsoft.Json

Now I don't know whether the reason is the new 3.14.0.0 of cs-script or whether the Newtonsoft.Json package was also recently updated to contain something that causes the above error.

My question:

Can you tell me what's going on here and/or how to resolve it?

uwe....@gmail.com

unread,
Aug 11, 2016, 7:23:15 AM8/11/16
to CS-Script, uwe....@gmail.com
Ha! Solved it with this solution:

The error indicated that the NuGet.exe shipped with cs-script was too old (somewhere from 2014, IIRC).

Solution:

I've downloaded the newest NuGet.exe and replaced the NuGet.exe in the "lib" folder of my cs-script installation.

I'm happy!

Oleg Shilo

unread,
Aug 11, 2016, 7:58:42 AM8/11/16
to cs-s...@googlegroups.com
>I'm happy!
Me too :)

I got a defect report a solution at the same time. Will replace nuget in the distro.

Thanks a lot,
Oleg 

Oleg Shilo
--------------------------------------------------------------------------------------------
Website: http://www.csscript.net
E-Mail: csscript...@gmail.com

--
You received this message because you are subscribed to the Google Groups "CS-Script" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cs-script+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

uwe....@gmail.com

unread,
Aug 11, 2016, 8:04:05 AM8/11/16
to CS-Script, osh...@gmail.com
NuGet is capable of updating itself:

NuGet.exe Update -self

Maybe this can be included somehow into cs-script (like let's say, update myself once a week or so).

Oleg Shilo

unread,
Aug 11, 2016, 10:26:15 PM8/11/16
to cs-s...@googlegroups.com
Great. Scheduling the update is problematic as it can interfere with the user script executions. It will also require elevation and this can be extremely annoying for the user. This is what I've done instead:
Inline image 1

A button from already elevated Config Console.

Thanks,
Oleg


Oleg Shilo
--------------------------------------------------------------------------------------------
Website: http://www.csscript.net
E-Mail: csscript...@gmail.com

--

uwe....@gmail.com

unread,
Aug 12, 2016, 2:12:03 AM8/12/16
to CS-Script, osh...@gmail.com
Is there also a way to trigger this via the command line?

My goal is to do everything via the command line.

Of course I could assume where NuGet.exe is located and call the update by myself, but I think it would be cool to have something like /updatenugetexe as an additional command line argument to cscs.exe.

Would something like this be possible?

Oleg Shilo

unread,
Aug 12, 2016, 9:15:00 AM8/12/16
to cs-s...@googlegroups.com
I do not like the idea of embedding the knowledge about an optional third-party dependency (nuget.exe) in the script engine core.    
However I do like the idea of updating via CLI. Fortunately the behavior you propose can be achieved without resorting to the script engine changes. Thus in very next release (within a few days) you will be able to do this:

Inline image 4

It will be possible because the release will include a special script updatenugetexe.cs. The simplest possible implementation of this script is as follows:    

//css_args /ac;

using System.Diagnostics;

using System;

 

void main()

{

    Process.Start("cmd.exe", "/K \"%CSSCRIPT_DIR%\\lib\\nuget.exe\" Update -self");

}


Though the release will have a little more advanced implementation with the std output redirected.


uwe....@gmail.com

unread,
Aug 12, 2016, 9:24:01 AM8/12/16
to CS-Script, osh...@gmail.com
Thanks a lot, Oleg, this looks very well-thought!

Oleg Shilo

unread,
Aug 12, 2016, 11:06:51 PM8/12/16
to CS-Script, osh...@gmail.com, uwe....@gmail.com
All done now. The new release just has been published: v3.14.1.0 
You can get it with 'choco.install cs-script'
Reply all
Reply to author
Forward
0 new messages