make it work with dotnet-script
Closed this issue · 2 comments
pitermarx commented
install dotnet-script
run dotnet script .\dotnet-script\test.csx
warn: Dotnet.Script.Core.Commands.ExecuteScriptCommand[0]
The script C:\github\Cake.Console\.\dotnet-script\test.csx is not cacheable. For caching and optimal performance, ensure that the script only contains NuGet references with pinned/exact versions.
warn: Dotnet.Script.DependencyModel.Context.CachedRestorer[0]
Unable to cache C:\Users\PedroMarques\AppData\Local\Temp\dotnet-script\C\github\Cake.Console\.\dotnet-script\net5.0\script.csproj. For caching and optimal performance, ensure that the script(s) references Nuget packages with a
pinned version.
System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection, Version=5.0.0.1, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Could not find or load a specific file. (0x80131621)
File name: 'Microsoft.Extensions.DependencyInjection, Version=5.0.0.1, Culture=neutral, PublicKeyToken=adb9793829ddae60'
---> System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection, Version=5.0.0.1, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at System.Reflection.Assembly.LoadFromResolveHandler(Object sender, ResolveEventArgs args)
at System.Runtime.Loader.AssemblyLoadContext.InvokeResolveEvent(ResolveEventHandler eventHandler, RuntimeAssembly assembly, String name)
at System.Runtime.Loader.AssemblyLoadContext.OnAssemblyResolve(RuntimeAssembly assembly, String assemblyFullName)
at Cake.Console.CakeHostBuilder.BuildScriptHost[T](ICakeArguments args)
at Cake.Console.CakeHostBuilder.BuildHost(IEnumerable`1 args)
at Submission#0.<<Initialize>>d__0.MoveNext() in C:\github\Cake.Console\dotnet-script\test.csx:line 9
--- End of stack trace from previous location ---
at Dotnet.Script.Core.ScriptRunner.Execute[TReturn](String dllPath, IEnumerable`1 commandLineArgs) in C:\Users\VssAdministrator\AppData\Local\Temp\tmpBFB\Dotnet.Script.Core\ScriptRunner.cs:line 110
badsim commented
Thread is quite old but maybe somebody else will use it. For me remedy was to use parameter
dotnet-script myfile.csx --isolated-load-context
as @seesharper mentioned in that post -> https://githubhot.com/index.php/repo/filipw/dotnet-script/issues/641
pitermarx commented
thank you!