diff --git a/src/Dotnet.Script.Core/Dotnet.Script.Core.csproj b/src/Dotnet.Script.Core/Dotnet.Script.Core.csproj index af458d70..3f978e58 100644 --- a/src/Dotnet.Script.Core/Dotnet.Script.Core.csproj +++ b/src/Dotnet.Script.Core/Dotnet.Script.Core.csproj @@ -4,7 +4,7 @@ A cross platform library allowing you to run C# (CSX) scripts with support for debugging and inline NuGet packages. Based on Roslyn. 0.29.1 filipw - netstandard2.0 + netstandard2.0 Dotnet.Script.Core Dotnet.Script.Core script;csx;csharp;roslyn @@ -34,7 +34,7 @@ - + diff --git a/src/Dotnet.Script.Core/ScriptCompiler.cs b/src/Dotnet.Script.Core/ScriptCompiler.cs index 7e59122a..1742c0d4 100644 --- a/src/Dotnet.Script.Core/ScriptCompiler.cs +++ b/src/Dotnet.Script.Core/ScriptCompiler.cs @@ -101,6 +101,16 @@ public virtual ScriptOptions CreateScriptOptions(ScriptContext context, IListhttps://github.com/filipw/dotnet-script.git git script;csx;csharp;roslyn;nuget - 0.8.0 + 0.9.0 A MetadataReferenceResolver that allows inline nuget references to be specified in script(csx) files. dotnet-script dotnet-script diff --git a/src/Dotnet.Script.DependencyModel/Dotnet.Script.DependencyModel.csproj b/src/Dotnet.Script.DependencyModel/Dotnet.Script.DependencyModel.csproj index 32eb28a8..ac233961 100644 --- a/src/Dotnet.Script.DependencyModel/Dotnet.Script.DependencyModel.csproj +++ b/src/Dotnet.Script.DependencyModel/Dotnet.Script.DependencyModel.csproj @@ -11,7 +11,7 @@ https://github.com/filipw/dotnet-script.git git script;csx;csharp;roslyn;omnisharp - 0.9.0 + 0.10.0 latest @@ -24,9 +24,8 @@ - + - diff --git a/src/Dotnet.Script.DependencyModel/ProjectSystem/NuGetUtilities.cs b/src/Dotnet.Script.DependencyModel/ProjectSystem/NuGetUtilities.cs index d4a64735..c45b98ce 100644 --- a/src/Dotnet.Script.DependencyModel/ProjectSystem/NuGetUtilities.cs +++ b/src/Dotnet.Script.DependencyModel/ProjectSystem/NuGetUtilities.cs @@ -1,70 +1,64 @@ using NuGet.Configuration; using System.Collections.Generic; +using System.Linq; namespace Dotnet.Script.DependencyModel.ProjectSystem { internal static class NuGetUtilities { - struct NuGetConfigSection + public static void CreateNuGetConfigFromLocation(string pathToEvaluate, string targetDirectory) { - public string Name; - public HashSet KeysForPathValues; - public bool AreAllValuesPaths; + var sourceSettings = Settings.LoadDefaultSettings(pathToEvaluate); + var targetSettings = new Settings(targetDirectory); + + CopySection(sourceSettings, targetSettings, "config"); + CopySection(sourceSettings, targetSettings, "bindingRedirects"); + CopySection(sourceSettings, targetSettings, "packageRestore"); + CopySection(sourceSettings, targetSettings, "solution"); + CopySection(sourceSettings, targetSettings, "packageSources"); + CopySection(sourceSettings, targetSettings, "packageSourceCredentials"); + CopySection(sourceSettings, targetSettings, "apikeys"); + CopySection(sourceSettings, targetSettings, "disabledPackageSources"); + CopySection(sourceSettings, targetSettings, "activePackageSource"); + + targetSettings.SaveToDisk(); } - static readonly NuGetConfigSection[] NuGetSections = + private static void CopySection(ISettings sourceSettings, ISettings targetSettings, string sectionName) { - new NuGetConfigSection { Name = "config", KeysForPathValues = new HashSet { "globalPackagesFolder", "repositoryPath" } }, - new NuGetConfigSection { Name = "bindingRedirects" }, - new NuGetConfigSection { Name = "packageRestore" }, - new NuGetConfigSection { Name = "solution" }, - new NuGetConfigSection { Name = "packageSources", AreAllValuesPaths = true }, - new NuGetConfigSection { Name = "packageSourceCredentials" }, - new NuGetConfigSection { Name = "apikeys" }, - new NuGetConfigSection { Name = "disabledPackageSources" }, - new NuGetConfigSection { Name = "activePackageSource" }, - }; + var existingAddItems = sourceSettings.GetSection(sectionName)?.Items.Where(item => item is object && (item is SourceItem || item is AddItem) && item.ElementName.ToLowerInvariant() == "add").Cast(); - // Create a NuGet file containing all properties with resolved absolute paths - public static void CreateNuGetConfigFromLocation(string pathToEvaluate, string targetDirectory) - { - var settings = Settings.LoadDefaultSettings(pathToEvaluate); - var target = new Settings(targetDirectory); + if (existingAddItems == null) + { + return; + } - var valuesToSet = new List(); - foreach (var section in NuGetSections) + foreach (var addItem in existingAddItems) { - // Resolve properly path values - valuesToSet.Clear(); - if (section.AreAllValuesPaths) + if (ShouldResolvePath(sectionName, addItem.Key)) { - // All values are paths - var values = settings.GetSettingValues(section.Name, true); - valuesToSet.AddRange(values); + targetSettings.AddOrUpdate(sectionName, new AddItem(addItem.Key, addItem.GetValueAsPath())); } else { - var values = settings.GetSettingValues(section.Name, false); - if (section.KeysForPathValues != null) - { - // Some values are path - foreach (var value in values) - { - if (section.KeysForPathValues.Contains(value.Key)) - { - var val = settings.GetValue(section.Name, value.Key, true); - value.Value = val; - } - - valuesToSet.Add(value); - } - } - else - // All values are not path - valuesToSet.AddRange(values); + targetSettings.AddOrUpdate(sectionName, addItem); } - target.SetValues(section.Name, valuesToSet); } } + + private static bool ShouldResolvePath(string sectionName, string key) + { + if (sectionName == "packageSources") + { + return true; + } + + if (sectionName == "config") + { + return key == "globalPackagesFolder" || key == "repositoryPath"; + } + + return false; + } } } diff --git a/src/Dotnet.Script.Desktop.Tests/Dotnet.Script.Desktop.Tests.csproj b/src/Dotnet.Script.Desktop.Tests/Dotnet.Script.Desktop.Tests.csproj index 4ce0115b..ef932a82 100644 --- a/src/Dotnet.Script.Desktop.Tests/Dotnet.Script.Desktop.Tests.csproj +++ b/src/Dotnet.Script.Desktop.Tests/Dotnet.Script.Desktop.Tests.csproj @@ -1,7 +1,7 @@ - + - net461 + net472 diff --git a/src/Dotnet.Script.Tests/NuGetUtilitiesTests.cs b/src/Dotnet.Script.Tests/NuGetUtilitiesTests.cs index e52cc640..35c5baa8 100644 --- a/src/Dotnet.Script.Tests/NuGetUtilitiesTests.cs +++ b/src/Dotnet.Script.Tests/NuGetUtilitiesTests.cs @@ -2,6 +2,7 @@ using NuGet.Configuration; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Runtime.InteropServices; using Xunit; @@ -213,9 +214,9 @@ public void ShouldGenerateEvaluatedNuGetConfigFile(string sourceNuGet, SettingsS { foreach (var expectedSetting in expectedSettings.Value) { - var value = settings.GetValue(expectedSettings.Key, expectedSetting.Key); + var value = settings.GetSection(expectedSettings.Key).Items.Cast().First(i => i.Key == expectedSetting.Key); var resolvedExpectedSetting = string.Format(expectedSetting.Value, sourceFolder, rootTokens); - Assert.Equal(resolvedExpectedSetting, value); + Assert.Equal(resolvedExpectedSetting, value.Value); } } } diff --git a/src/Dotnet.Script.Tests/TestFixtures/LocalNuGetConfig/NuGet.Config b/src/Dotnet.Script.Tests/TestFixtures/LocalNuGetConfig/NuGet.Config index 368b3ea5..5e150b6e 100644 --- a/src/Dotnet.Script.Tests/TestFixtures/LocalNuGetConfig/NuGet.Config +++ b/src/Dotnet.Script.Tests/TestFixtures/LocalNuGetConfig/NuGet.Config @@ -1,6 +1,7 @@  + \ No newline at end of file diff --git a/src/Dotnet.Script/Dotnet.Script.csproj b/src/Dotnet.Script/Dotnet.Script.csproj index 4ecf000e..0ab0c559 100644 --- a/src/Dotnet.Script/Dotnet.Script.csproj +++ b/src/Dotnet.Script/Dotnet.Script.csproj @@ -1,7 +1,7 @@  Dotnet CLI tool allowing you to run C# (CSX) scripts. - 0.29.1 + 0.30.0 filipw Dotnet.Script netcoreapp2.1 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy