diff --git a/help.txt b/help.txt index 24241261..d6d1d55c 100644 --- a/help.txt +++ b/help.txt @@ -1,4 +1,4 @@ -C# Script execution engine (.NET Core). Version 4.8.13.0. +C# Script execution engine (.NET Core). Version 4.8.14.1. Copyright (C) 2004-2023 Oleg Shilo. diff --git a/src/cscs/AssemblyExecutor.cs b/src/cscs/AssemblyExecutor.cs index c3cfad4e..3228f665 100644 --- a/src/cscs/AssemblyExecutor.cs +++ b/src/cscs/AssemblyExecutor.cs @@ -189,7 +189,9 @@ void ExecuteLoadedAssembly(string filename, string[] args, SystemWideLock asmLoc asmLock?.Release(); } - SetScriptReflection(assembly, Path.GetFullPath(filename), true); + + + SetScriptReflection(assembly, Path.GetFullPath(filename), "CSS_SCRIPTLOCATIONREFLECTION".GetEnvar().HasText()); InvokeStaticMain(assembly, args); } catch (FileLoadException e) diff --git a/src/cscs/HelpProvider.cs b/src/cscs/HelpProvider.cs index 0a85267f..7f963df1 100644 --- a/src/cscs/HelpProvider.cs +++ b/src/cscs/HelpProvider.cs @@ -982,8 +982,8 @@ static AppArgs() "Even when the script loaded in-memory (InMemoryAssembly setting) but not from the original file. " + "(e.g. var location = Environment.GetEnvironmentVariable(\"location:\" + Assembly.GetExecutingAssembly().GetHashCode()); ", " ", - "Note that by default setting of 'location:' is disabled. You can enable it by calling " + - " 'CSScript.EnableScriptLocationReflection = true'.", + "Note that by default setting of 'location:' is disabled. You can enable it by setting" + + " 'CSS_SCRIPTLOCATIONREFLECTION' environment variable to non empty string.", " ", "The following is the optional set of environment variables that the script engine uses to improve the user experience:", " ", diff --git a/src/cscs/NuGet.Core.cs b/src/cscs/NuGet.Core.cs index 2ed728f7..76bc1333 100644 --- a/src/cscs/NuGet.Core.cs +++ b/src/cscs/NuGet.Core.cs @@ -29,7 +29,7 @@ class NuGet static NuGetCore nuget = new NuGetCore(); static public string NuGetCacheView => Directory.Exists(NuGetCache) ? NuGetCache : ""; - static public string NuGetCache => CSExecutor.options.legacyNugetSupport ? NuGetCore.NuGetCache : NuGetDotnet.NuGetCache; + static public string NuGetCache => CSExecutor.options.legacyNugetSupport ? NuGetCore.NuGetCache : NuGetNewAlgorithm.NuGetCache; static public string NuGetExeView => (NuGetCore.NuGetExe.FileExists() || NuGetCore.NuGetExe == "dotnet") ? NuGetCore.NuGetExe : ""; @@ -51,7 +51,7 @@ static public void ListPackages() static public string[] Resolve(string[] packages, bool suppressDownloading, string script) => CSExecutor.options.legacyNugetSupport ? NuGetCore.Resolve(packages, suppressDownloading, script) : - NuGetDotnet.FindAssembliesOf(packages, suppressDownloading, script); + NuGetNewAlgorithm.FindAssembliesOf(packages, suppressDownloading, script); } class NuGetCore @@ -126,8 +126,12 @@ static public void InstallPackage(string packageNameMask, string version = null, { Task.Run(() => { - nuget_dir.DeleteDir(); - ClearAnabdonedNugetDirs(nuget_dir.GetDirName()); + try + { + nuget_dir.DeleteDir(); + ClearAnabdonedNugetDirs(nuget_dir.GetDirName()); + } + catch { } }); } } @@ -139,8 +143,12 @@ static void ClearAnabdonedNugetDirs(string nuget_root) { if (int.TryParse(item.GetFileName(), out int proc_id)) { - if (Process.GetProcessById(proc_id) == null) - try { item.DeleteDir(); } catch { } + try + { + if (Process.GetProcessById(proc_id) == null) + item.DeleteDir(); + } + catch { } } } } @@ -351,7 +359,7 @@ static PackageInfo FindPackage(string name, string version) .ToArray(); return packages.FirstOrDefault(x => string.Compare(x.Name, name, StringComparison.OrdinalIgnoreCase) == 0 && - (version.IsEmpty() || version == x.Version)); + (version.IsEmpty() || version == "*" || version == x.Version)); } static public string[] Resolve(string[] packages, bool suppressDownloading, string script) @@ -456,7 +464,7 @@ static public string[] Resolve(string[] packages, bool suppressDownloading, stri } } - class NuGetDotnet + class NuGetNewAlgorithm { static string[] GetPackagesFromConfigFileOfScript(string scriptFile) { diff --git a/src/cscs/Settings.cs b/src/cscs/Settings.cs index 840c1fff..5077e02f 100644 --- a/src/cscs/Settings.cs +++ b/src/cscs/Settings.cs @@ -127,11 +127,13 @@ public bool ResolveRelativeFromParentScriptLocation /// /// Gets or sets a value indicating whether legacy NuGet support is enabled (default) or disabled. + /// See https://github.com/oleg-shilo/cs-script/wiki/NuGet-Support /// /// /// true if legacy NuGet support is enabled; otherwise, false. /// [Description(@"Gets or sets a value indicating whether legacy NuGet support is enabled (default) or disabled. +See https://github.com/oleg-shilo/cs-script/wiki/NuGet-Support `true` if legacy NuGet support is enabled; otherwise, `false`.")] public bool LegacyNugetSupport { get; set; } = true;