From c1dd7ce00cd359c1c005a8d3e4bcb0dc8a6227b0 Mon Sep 17 00:00:00 2001 From: Bernhard Richter Date: Tue, 28 May 2019 18:10:08 +0200 Subject: [PATCH 1/9] Fixed obsolete NuGet API --- ...Dotnet.Script.DependencyModel.NuGet.csproj | 2 +- .../Dotnet.Script.DependencyModel.csproj | 4 +- .../ProjectSystem/NuGetUtilities.cs | 88 +++++++++---------- src/Dotnet.Script/Dotnet.Script.csproj | 2 +- 4 files changed, 45 insertions(+), 51 deletions(-) diff --git a/src/Dotnet.Script.DependencyModel.Nuget/Dotnet.Script.DependencyModel.NuGet.csproj b/src/Dotnet.Script.DependencyModel.Nuget/Dotnet.Script.DependencyModel.NuGet.csproj index 6d87c4b4..055340b5 100644 --- a/src/Dotnet.Script.DependencyModel.Nuget/Dotnet.Script.DependencyModel.NuGet.csproj +++ b/src/Dotnet.Script.DependencyModel.Nuget/Dotnet.Script.DependencyModel.NuGet.csproj @@ -8,7 +8,7 @@ https://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..59b3b16a 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,7 +24,7 @@ - + diff --git a/src/Dotnet.Script.DependencyModel/ProjectSystem/NuGetUtilities.cs b/src/Dotnet.Script.DependencyModel/ProjectSystem/NuGetUtilities.cs index d4a64735..79515a67 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.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/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 From 11b287db4a86f193bcab0c1e50dacc5b8a33ad9f Mon Sep 17 00:00:00 2001 From: Bernhard Richter Date: Tue, 28 May 2019 18:35:40 +0200 Subject: [PATCH 2/9] Fixed test --- src/Dotnet.Script.Tests/NuGetUtilitiesTests.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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); } } } From 0ea533dbe92ab4c6f181f6fb26c9089fbbe36569 Mon Sep 17 00:00:00 2001 From: filipw Date: Wed, 29 May 2019 10:54:50 +0200 Subject: [PATCH 3/9] run tests as net472 --- src/Dotnet.Script.Core/Dotnet.Script.Core.csproj | 4 ++-- .../Dotnet.Script.Desktop.Tests.csproj | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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.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 From ba028b0529776b0e4e87a8e66e11832e92dd9480 Mon Sep 17 00:00:00 2001 From: filipw Date: Wed, 29 May 2019 11:00:00 +0200 Subject: [PATCH 4/9] fixed NuGetUtilities and cross compile dependency model dll --- .../Dotnet.Script.DependencyModel.csproj | 2 +- .../ProjectSystem/NuGetUtilities.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Dotnet.Script.DependencyModel/Dotnet.Script.DependencyModel.csproj b/src/Dotnet.Script.DependencyModel/Dotnet.Script.DependencyModel.csproj index 59b3b16a..6a966adf 100644 --- a/src/Dotnet.Script.DependencyModel/Dotnet.Script.DependencyModel.csproj +++ b/src/Dotnet.Script.DependencyModel/Dotnet.Script.DependencyModel.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netstandard2.0;net472 dotnet-script dotnet-script Provides runtime and compilation dependency resolution for dotnet-script based scripts. diff --git a/src/Dotnet.Script.DependencyModel/ProjectSystem/NuGetUtilities.cs b/src/Dotnet.Script.DependencyModel/ProjectSystem/NuGetUtilities.cs index 79515a67..315065f9 100644 --- a/src/Dotnet.Script.DependencyModel/ProjectSystem/NuGetUtilities.cs +++ b/src/Dotnet.Script.DependencyModel/ProjectSystem/NuGetUtilities.cs @@ -26,7 +26,7 @@ public static void CreateNuGetConfigFromLocation(string pathToEvaluate, string t private static void CopySection(ISettings sourceSettings, ISettings targetSettings, string sectionName) { - var existingAddItems = sourceSettings.GetSection(sectionName)?.Items.Cast(); + var existingAddItems = sourceSettings.GetSection(sectionName)?.Items.Where(item => item is object && item is SourceItem && item.ElementName.ToLowerInvariant() == "add").Cast(); if (existingAddItems == null) { From 299dd504422cc00cf51e6d1d3440cc68065a037c Mon Sep 17 00:00:00 2001 From: filipw Date: Wed, 29 May 2019 11:00:23 +0200 Subject: [PATCH 5/9] should build on nix --- .../Dotnet.Script.DependencyModel.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Dotnet.Script.DependencyModel/Dotnet.Script.DependencyModel.csproj b/src/Dotnet.Script.DependencyModel/Dotnet.Script.DependencyModel.csproj index 6a966adf..ba2b0b29 100644 --- a/src/Dotnet.Script.DependencyModel/Dotnet.Script.DependencyModel.csproj +++ b/src/Dotnet.Script.DependencyModel/Dotnet.Script.DependencyModel.csproj @@ -26,6 +26,7 @@ + From 9e9596107a12cf061fb918f0eda8bb879f83f004 Mon Sep 17 00:00:00 2001 From: filipw Date: Wed, 29 May 2019 11:02:38 +0200 Subject: [PATCH 6/9] added clear to the test fixture to make the test more robust --- .../TestFixtures/LocalNuGetConfig/NuGet.Config | 1 + 1 file changed, 1 insertion(+) 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 From 4585beb4a14150bd2a4ab9b020b92cc30df349af Mon Sep 17 00:00:00 2001 From: filipw Date: Wed, 29 May 2019 11:16:50 +0200 Subject: [PATCH 7/9] fix the fix --- .../ProjectSystem/NuGetUtilities.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Dotnet.Script.DependencyModel/ProjectSystem/NuGetUtilities.cs b/src/Dotnet.Script.DependencyModel/ProjectSystem/NuGetUtilities.cs index 315065f9..c45b98ce 100644 --- a/src/Dotnet.Script.DependencyModel/ProjectSystem/NuGetUtilities.cs +++ b/src/Dotnet.Script.DependencyModel/ProjectSystem/NuGetUtilities.cs @@ -26,7 +26,7 @@ public static void CreateNuGetConfigFromLocation(string pathToEvaluate, string t private static void CopySection(ISettings sourceSettings, ISettings targetSettings, string sectionName) { - var existingAddItems = sourceSettings.GetSection(sectionName)?.Items.Where(item => item is object && item is SourceItem && item.ElementName.ToLowerInvariant() == "add").Cast(); + var existingAddItems = sourceSettings.GetSection(sectionName)?.Items.Where(item => item is object && (item is SourceItem || item is AddItem) && item.ElementName.ToLowerInvariant() == "add").Cast(); if (existingAddItems == null) { From d650bf8ca98fc564c4f91da2f265635a5b9c9ce9 Mon Sep 17 00:00:00 2001 From: filipw Date: Wed, 29 May 2019 15:51:55 +0200 Subject: [PATCH 8/9] =?UTF-8?q?=F0=9F=98=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Dotnet.Script.Core/ScriptCompiler.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) 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, IList Date: Wed, 29 May 2019 16:09:37 +0200 Subject: [PATCH 9/9] no more cross compile --- .../Dotnet.Script.DependencyModel.csproj | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Dotnet.Script.DependencyModel/Dotnet.Script.DependencyModel.csproj b/src/Dotnet.Script.DependencyModel/Dotnet.Script.DependencyModel.csproj index ba2b0b29..ac233961 100644 --- a/src/Dotnet.Script.DependencyModel/Dotnet.Script.DependencyModel.csproj +++ b/src/Dotnet.Script.DependencyModel/Dotnet.Script.DependencyModel.csproj @@ -1,7 +1,7 @@  - netstandard2.0;net472 + netstandard2.0 dotnet-script dotnet-script Provides runtime and compilation dependency resolution for dotnet-script based scripts. @@ -26,8 +26,6 @@ - - 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