提交 f081e1e7 编写于 作者: C Charles Stoner

Remove NuGetPackageResolver implementation

上级 e52caf41
......@@ -60,14 +60,6 @@
"lib/net40/Moq.dll": {}
}
},
"Newtonsoft.Json/6.0.4": {
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
},
"System.AppContext/4.0.0": {
"dependencies": {
"System.Runtime": "[4.0.0, )"
......@@ -521,31 +513,6 @@
"package/services/metadata/core-properties/98e2d674c8ec4e5fbda07a9e01280647.psmdcp"
]
},
"Newtonsoft.Json/6.0.4": {
"sha512": "FyQLmEpjsCrEP+znauLDGAi+h6i9YnaMkITlfIoiM4RYyX3nki306bTHsr/0okiIvIc7BJhQTbOAIZVocccFUw==",
"type": "Package",
"files": [
"[Content_Types].xml",
"_rels/.rels",
"lib/net20/Newtonsoft.Json.dll",
"lib/net20/Newtonsoft.Json.xml",
"lib/net35/Newtonsoft.Json.dll",
"lib/net35/Newtonsoft.Json.xml",
"lib/net40/Newtonsoft.Json.dll",
"lib/net40/Newtonsoft.Json.xml",
"lib/net45/Newtonsoft.Json.dll",
"lib/net45/Newtonsoft.Json.xml",
"lib/netcore45/Newtonsoft.Json.dll",
"lib/netcore45/Newtonsoft.Json.xml",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.xml",
"Newtonsoft.Json.nuspec",
"package/services/metadata/core-properties/87a0a4e28d50417ea282e20f81bc6477.psmdcp",
"tools/install.ps1"
]
},
"System.AppContext/4.0.0": {
"sha512": "gUoYgAWDC3+xhKeU5KSLbYDhTdBYk9GssrMSCcWUADzOglW+s0AmwVhOUGt2tL5xUl7ZXoYTPdA88zCgKrlG0A==",
"type": "Package",
......
......@@ -60,14 +60,6 @@
"lib/net40/Moq.dll": {}
}
},
"Newtonsoft.Json/6.0.4": {
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
},
"System.AppContext/4.0.0": {
"dependencies": {
"System.Runtime": "[4.0.0, )"
......@@ -378,14 +370,6 @@
"lib/net40/Moq.dll": {}
}
},
"Newtonsoft.Json/6.0.4": {
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
},
"System.AppContext/4.0.0": {
"dependencies": {
"System.Runtime": "[4.0.0, )"
......@@ -806,31 +790,6 @@
"package/services/metadata/core-properties/98e2d674c8ec4e5fbda07a9e01280647.psmdcp"
]
},
"Newtonsoft.Json/6.0.4": {
"sha512": "FyQLmEpjsCrEP+znauLDGAi+h6i9YnaMkITlfIoiM4RYyX3nki306bTHsr/0okiIvIc7BJhQTbOAIZVocccFUw==",
"type": "Package",
"files": [
"[Content_Types].xml",
"_rels/.rels",
"lib/net20/Newtonsoft.Json.dll",
"lib/net20/Newtonsoft.Json.xml",
"lib/net35/Newtonsoft.Json.dll",
"lib/net35/Newtonsoft.Json.xml",
"lib/net40/Newtonsoft.Json.dll",
"lib/net40/Newtonsoft.Json.xml",
"lib/net45/Newtonsoft.Json.dll",
"lib/net45/Newtonsoft.Json.xml",
"lib/netcore45/Newtonsoft.Json.dll",
"lib/netcore45/Newtonsoft.Json.xml",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.xml",
"Newtonsoft.Json.nuspec",
"package/services/metadata/core-properties/87a0a4e28d50417ea282e20f81bc6477.psmdcp",
"tools/install.ps1"
]
},
"System.AppContext/4.0.0": {
"sha512": "gUoYgAWDC3+xhKeU5KSLbYDhTdBYk9GssrMSCcWUADzOglW+s0AmwVhOUGt2tL5xUl7ZXoYTPdA88zCgKrlG0A==",
"type": "Package",
......
......@@ -60,14 +60,6 @@
"lib/net40/Moq.dll": {}
}
},
"Newtonsoft.Json/6.0.4": {
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
},
"System.AppContext/4.0.0": {
"dependencies": {
"System.Runtime": "[4.0.0, )"
......@@ -488,31 +480,6 @@
"package/services/metadata/core-properties/98e2d674c8ec4e5fbda07a9e01280647.psmdcp"
]
},
"Newtonsoft.Json/6.0.4": {
"sha512": "FyQLmEpjsCrEP+znauLDGAi+h6i9YnaMkITlfIoiM4RYyX3nki306bTHsr/0okiIvIc7BJhQTbOAIZVocccFUw==",
"type": "Package",
"files": [
"[Content_Types].xml",
"_rels/.rels",
"lib/net20/Newtonsoft.Json.dll",
"lib/net20/Newtonsoft.Json.xml",
"lib/net35/Newtonsoft.Json.dll",
"lib/net35/Newtonsoft.Json.xml",
"lib/net40/Newtonsoft.Json.dll",
"lib/net40/Newtonsoft.Json.xml",
"lib/net45/Newtonsoft.Json.dll",
"lib/net45/Newtonsoft.Json.xml",
"lib/netcore45/Newtonsoft.Json.dll",
"lib/netcore45/Newtonsoft.Json.xml",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.xml",
"Newtonsoft.Json.nuspec",
"package/services/metadata/core-properties/87a0a4e28d50417ea282e20f81bc6477.psmdcp",
"tools/install.ps1"
]
},
"System.AppContext/4.0.0": {
"sha512": "gUoYgAWDC3+xhKeU5KSLbYDhTdBYk9GssrMSCcWUADzOglW+s0AmwVhOUGt2tL5xUl7ZXoYTPdA88zCgKrlG0A==",
"type": "Package",
......
......@@ -60,14 +60,6 @@
"lib/net40/Moq.dll": {}
}
},
"Newtonsoft.Json/6.0.4": {
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
},
"System.AppContext/4.0.0": {
"dependencies": {
"System.Runtime": "[4.0.0, )"
......@@ -488,31 +480,6 @@
"package/services/metadata/core-properties/98e2d674c8ec4e5fbda07a9e01280647.psmdcp"
]
},
"Newtonsoft.Json/6.0.4": {
"sha512": "FyQLmEpjsCrEP+znauLDGAi+h6i9YnaMkITlfIoiM4RYyX3nki306bTHsr/0okiIvIc7BJhQTbOAIZVocccFUw==",
"type": "Package",
"files": [
"[Content_Types].xml",
"_rels/.rels",
"lib/net20/Newtonsoft.Json.dll",
"lib/net20/Newtonsoft.Json.xml",
"lib/net35/Newtonsoft.Json.dll",
"lib/net35/Newtonsoft.Json.xml",
"lib/net40/Newtonsoft.Json.dll",
"lib/net40/Newtonsoft.Json.xml",
"lib/net45/Newtonsoft.Json.dll",
"lib/net45/Newtonsoft.Json.xml",
"lib/netcore45/Newtonsoft.Json.dll",
"lib/netcore45/Newtonsoft.Json.xml",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.xml",
"Newtonsoft.Json.nuspec",
"package/services/metadata/core-properties/87a0a4e28d50417ea282e20f81bc6477.psmdcp",
"tools/install.ps1"
]
},
"System.AppContext/4.0.0": {
"sha512": "gUoYgAWDC3+xhKeU5KSLbYDhTdBYk9GssrMSCcWUADzOglW+s0AmwVhOUGt2tL5xUl7ZXoYTPdA88zCgKrlG0A==",
"type": "Package",
......
......@@ -28,14 +28,6 @@
"lib/net45/_._": {}
}
},
"Newtonsoft.Json/6.0.4": {
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
},
"System.AppContext/4.0.0": {
"dependencies": {
"System.Runtime": "[4.0.0, )"
......@@ -385,31 +377,6 @@
"runtimes/aot/lib/netcore50/System.Xml.Serialization.dll"
]
},
"Newtonsoft.Json/6.0.4": {
"sha512": "FyQLmEpjsCrEP+znauLDGAi+h6i9YnaMkITlfIoiM4RYyX3nki306bTHsr/0okiIvIc7BJhQTbOAIZVocccFUw==",
"type": "Package",
"files": [
"[Content_Types].xml",
"_rels/.rels",
"lib/net20/Newtonsoft.Json.dll",
"lib/net20/Newtonsoft.Json.xml",
"lib/net35/Newtonsoft.Json.dll",
"lib/net35/Newtonsoft.Json.xml",
"lib/net40/Newtonsoft.Json.dll",
"lib/net40/Newtonsoft.Json.xml",
"lib/net45/Newtonsoft.Json.dll",
"lib/net45/Newtonsoft.Json.xml",
"lib/netcore45/Newtonsoft.Json.dll",
"lib/netcore45/Newtonsoft.Json.xml",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.xml",
"Newtonsoft.Json.nuspec",
"package/services/metadata/core-properties/87a0a4e28d50417ea282e20f81bc6477.psmdcp",
"tools/install.ps1"
]
},
"System.AppContext/4.0.0": {
"sha512": "gUoYgAWDC3+xhKeU5KSLbYDhTdBYk9GssrMSCcWUADzOglW+s0AmwVhOUGt2tL5xUl7ZXoYTPdA88zCgKrlG0A==",
"type": "Package",
......
......@@ -250,14 +250,9 @@ private Dispatcher Dispatcher
private static MetadataReferenceResolver CreateMetadataReferenceResolver(IMetadataService metadataService, ImmutableArray<string> searchPaths, string baseDirectory)
{
var userProfilePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
var packagesDirectory = (userProfilePath == null) ?
null :
PathUtilities.CombineAbsoluteAndRelativePaths(userProfilePath, PathUtilities.CombinePossiblyRelativeAndRelativePaths(".nuget", "packages"));
return new RuntimeMetadataReferenceResolver(
new RelativePathResolver(searchPaths, baseDirectory),
string.IsNullOrEmpty(packagesDirectory) ? null : new NuGetPackageResolverImpl(packagesDirectory),
null,
GacFileResolver.IsAvailable ? new GacFileResolver(preferredCulture: CultureInfo.CurrentCulture) : null,
(path, properties) => metadataService.GetReference(path, properties));
}
......
{
"dependencies": {
"Microsoft.Composition": "1.0.27",
"Newtonsoft.Json": "6.0.4",
"System.Collections": "4.0.10",
"System.Diagnostics.Debug": "4.0.10",
"System.Globalization": "4.0.10",
......
......@@ -28,14 +28,6 @@
"lib/net45/_._": {}
}
},
"Newtonsoft.Json/6.0.4": {
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
},
"System.AppContext/4.0.0": {
"dependencies": {
"System.Runtime": "[4.0.0, )"
......@@ -385,31 +377,6 @@
"runtimes/aot/lib/netcore50/System.Xml.Serialization.dll"
]
},
"Newtonsoft.Json/6.0.4": {
"sha512": "FyQLmEpjsCrEP+znauLDGAi+h6i9YnaMkITlfIoiM4RYyX3nki306bTHsr/0okiIvIc7BJhQTbOAIZVocccFUw==",
"type": "Package",
"files": [
"[Content_Types].xml",
"_rels/.rels",
"lib/net20/Newtonsoft.Json.dll",
"lib/net20/Newtonsoft.Json.xml",
"lib/net35/Newtonsoft.Json.dll",
"lib/net35/Newtonsoft.Json.xml",
"lib/net40/Newtonsoft.Json.dll",
"lib/net40/Newtonsoft.Json.xml",
"lib/net45/Newtonsoft.Json.dll",
"lib/net45/Newtonsoft.Json.xml",
"lib/netcore45/Newtonsoft.Json.dll",
"lib/netcore45/Newtonsoft.Json.xml",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.xml",
"Newtonsoft.Json.nuspec",
"package/services/metadata/core-properties/87a0a4e28d50417ea282e20f81bc6477.psmdcp",
"tools/install.ps1"
]
},
"System.AppContext/4.0.0": {
"sha512": "gUoYgAWDC3+xhKeU5KSLbYDhTdBYk9GssrMSCcWUADzOglW+s0AmwVhOUGt2tL5xUl7ZXoYTPdA88zCgKrlG0A==",
"type": "Package",
......@@ -1197,7 +1164,6 @@
"projectFileDependencyGroups": {
"": [
"Microsoft.Composition >= 1.0.27",
"Newtonsoft.Json >= 6.0.4",
"System.Collections >= 4.0.10",
"System.Diagnostics.Debug >= 4.0.10",
"System.Globalization >= 4.0.10",
......
......@@ -39,14 +39,6 @@
"lib/net45/_._": {}
}
},
"Newtonsoft.Json/6.0.4": {
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
},
"System.AppContext/4.0.0": {
"dependencies": {
"System.Runtime": "[4.0.0, )"
......@@ -427,31 +419,6 @@
"ref/wpa81/_._"
]
},
"Newtonsoft.Json/6.0.4": {
"sha512": "FyQLmEpjsCrEP+znauLDGAi+h6i9YnaMkITlfIoiM4RYyX3nki306bTHsr/0okiIvIc7BJhQTbOAIZVocccFUw==",
"type": "Package",
"files": [
"[Content_Types].xml",
"_rels/.rels",
"lib/net20/Newtonsoft.Json.dll",
"lib/net20/Newtonsoft.Json.xml",
"lib/net35/Newtonsoft.Json.dll",
"lib/net35/Newtonsoft.Json.xml",
"lib/net40/Newtonsoft.Json.dll",
"lib/net40/Newtonsoft.Json.xml",
"lib/net45/Newtonsoft.Json.dll",
"lib/net45/Newtonsoft.Json.xml",
"lib/netcore45/Newtonsoft.Json.dll",
"lib/netcore45/Newtonsoft.Json.xml",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.xml",
"Newtonsoft.Json.nuspec",
"package/services/metadata/core-properties/87a0a4e28d50417ea282e20f81bc6477.psmdcp",
"tools/install.ps1"
]
},
"System.AppContext/4.0.0": {
"sha512": "gUoYgAWDC3+xhKeU5KSLbYDhTdBYk9GssrMSCcWUADzOglW+s0AmwVhOUGt2tL5xUl7ZXoYTPdA88zCgKrlG0A==",
"type": "Package",
......
......@@ -172,14 +172,9 @@ public void Initialize(Type replServiceProviderType, string cultureName)
private MetadataReferenceResolver CreateMetadataReferenceResolver(ImmutableArray<string> searchPaths, string baseDirectory)
{
var userProfilePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
var packagesDirectory = string.IsNullOrEmpty(userProfilePath) ?
null :
Path.Combine(userProfilePath, Path.Combine(".nuget", "packages"));
return new RuntimeMetadataReferenceResolver(
new RelativePathResolver(searchPaths, baseDirectory),
string.IsNullOrEmpty(packagesDirectory) ? null : new NuGetPackageResolverImpl(packagesDirectory),
null,
GacFileResolver.IsAvailable ? new GacFileResolver(preferredCulture: CultureInfo.CurrentCulture) : null,
(path, properties) => new ShadowCopyReference(_metadataFileProvider, path, properties));
}
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
extern alias WORKSPACES;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Roslyn.Utilities;
using System;
using System.Collections.Immutable;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using NuGetPackageResolver = WORKSPACES::Microsoft.CodeAnalysis.Scripting.Hosting.NuGetPackageResolver;
namespace Microsoft.CodeAnalysis.Interactive
{
internal sealed class NuGetPackageResolverImpl : NuGetPackageResolver
{
private const string ProjectJsonFramework = "net46";
private const string ProjectLockJsonFramework = ".NETFramework,Version=v4.6";
private const string EmptyNuGetConfig =
@"<?xml version=""1.0"" encoding=""utf-8""?>
<configuration>
<packageRestore>
<add key=""enabled"" value=""True"" />
<add key=""automatic"" value=""False"" />
</packageRestore>
<packageSources/>
</configuration>";
private readonly string _packagesDirectory;
private readonly Action<ProcessStartInfo> _restore;
internal NuGetPackageResolverImpl(string packagesDirectory, Action<ProcessStartInfo> restore = null)
{
Debug.Assert(PathUtilities.IsAbsolute(packagesDirectory));
_packagesDirectory = packagesDirectory;
_restore = restore ?? NuGetRestore;
}
internal new static bool TryParsePackageReference(string reference, out string name, out string version)
{
return NuGetPackageResolver.TryParsePackageReference(reference, out name, out version);
}
internal override ImmutableArray<string> ResolveNuGetPackage(string packageName, string packageVersion)
{
try
{
var tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("D"));
var tempDir = Directory.CreateDirectory(tempPath);
try
{
// Create project.json.
var projectJsonPath = Path.Combine(tempPath, "project.json");
using (var stream = File.OpenWrite(projectJsonPath))
using (var writer = new StreamWriter(stream))
{
WriteProjectJson(writer, packageName, packageVersion);
}
// Create nuget.config with no package sources so restore
// uses the local cache only, no downloading.
var configPath = Path.Combine(tempPath, "nuget.config");
File.WriteAllText(configPath, EmptyNuGetConfig);
// Run "nuget.exe restore project.json -configfile nuget.config"
// to generate project.lock.json.
NuGetRestore(projectJsonPath, configPath);
// Read the references from project.lock.json.
var projectLockJsonPath = Path.Combine(tempPath, "project.lock.json");
using (var stream = File.OpenRead(projectLockJsonPath))
using (var reader = new StreamReader(stream))
{
return ReadProjectLockJson(_packagesDirectory, reader);
}
}
finally
{
tempDir.Delete(recursive: true);
}
}
catch (IOException)
{
}
catch (UnauthorizedAccessException)
{
}
return ImmutableArray<string>.Empty;
}
/// <summary>
/// Generate a project.json file with the packages as "dependencies".
/// </summary>
internal static void WriteProjectJson(TextWriter writer, string packageName, string packageVersion)
{
using (var jsonWriter = new JsonTextWriter(writer))
{
jsonWriter.Formatting = Newtonsoft.Json.Formatting.Indented;
jsonWriter.WriteStartObject();
// "dependencies" : { "packageName" : "packageVersion" }
jsonWriter.WritePropertyName("dependencies");
jsonWriter.WriteStartObject();
jsonWriter.WritePropertyName(packageName, escape: true);
jsonWriter.WriteValue(packageVersion);
jsonWriter.WriteEndObject();
// "frameworks" : { "net46" : {} }
jsonWriter.WritePropertyName("frameworks");
jsonWriter.WriteStartObject();
jsonWriter.WritePropertyName(ProjectJsonFramework, escape: true);
jsonWriter.WriteStartObject();
jsonWriter.WriteEndObject();
jsonWriter.WriteEndObject();
jsonWriter.WriteEndObject();
}
}
/// <summary>
/// Read the references from the project.lock.json file.
/// </summary>
internal static ImmutableArray<string> ReadProjectLockJson(string packagesDirectory, TextReader reader)
{
JObject obj;
using (var jsonReader = new JsonTextReader(reader))
{
obj = JObject.Load(jsonReader);
}
var builder = ArrayBuilder<string>.GetInstance();
var targets = (JObject)GetPropertyValue(obj, "targets");
foreach (var target in targets)
{
if (target.Key == ProjectLockJsonFramework)
{
foreach (var package in (JObject)target.Value)
{
var packageRoot = Path.Combine(packagesDirectory, package.Key);
var runtime = (JObject)GetPropertyValue((JObject)package.Value, "runtime");
if (runtime == null)
{
continue;
}
foreach (var item in runtime)
{
var relativePath = item.Key;
// Ignore placeholder "_._" files.
var name = Path.GetFileName(relativePath);
if (string.Equals(name, "_._", StringComparison.InvariantCulture))
{
continue;
}
builder.Add(Path.Combine(packageRoot, relativePath));
}
}
break;
}
}
return builder.ToImmutableAndFree();
}
private static JToken GetPropertyValue(JObject obj, string propertyName)
{
JToken value;
obj.TryGetValue(propertyName, out value);
return value;
}
private void NuGetRestore(string projectJsonPath, string configPath)
{
// Load nuget.exe from same directory as current assembly.
var nugetExePath = Path.Combine(
Path.GetDirectoryName(
CorLightup.Desktop.GetAssemblyLocation(typeof(NuGetPackageResolverImpl).GetTypeInfo().Assembly)),
"nuget.exe");
var startInfo = new ProcessStartInfo()
{
FileName = nugetExePath,
Arguments = $"restore \"{projectJsonPath}\" -ConfigFile \"{configPath}\" -PackagesDirectory \"{_packagesDirectory}\"",
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
};
_restore(startInfo);
}
private static void NuGetRestore(ProcessStartInfo startInfo)
{
var process = Process.Start(startInfo);
// Should echo output and errors to InteractiveWindow.
process.StandardOutput.ReadToEndAsync();
process.StandardError.ReadToEndAsync();
process.WaitForExit();
}
}
}
......@@ -95,7 +95,6 @@
<Compile Include="Interactive\Core\HostObject\SearchPaths.cs" />
<Compile Include="Interactive\Core\SerializableAssemblyLoadResult.cs" />
<Compile Include="Interactive\Core\HostObject\SynchronizedVersionedList.cs" />
<Compile Include="Interactive\Core\NuGetPackageResolverImpl.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="Interactive\Core\InteractiveHost.LazyRemoteService.cs" />
......
{
"dependencies": {
"Microsoft.Composition": "1.0.27",
"Newtonsoft.Json": "6.0.4",
"System.Collections": "4.0.10",
"System.Diagnostics.Debug": "4.0.10",
"System.Globalization": "4.0.10",
......
......@@ -28,14 +28,6 @@
"lib/net45/_._": {}
}
},
"Newtonsoft.Json/6.0.4": {
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
},
"System.AppContext/4.0.0": {
"dependencies": {
"System.Runtime": "[4.0.0, )"
......@@ -385,31 +377,6 @@
"runtimes/aot/lib/netcore50/System.Xml.Serialization.dll"
]
},
"Newtonsoft.Json/6.0.4": {
"sha512": "FyQLmEpjsCrEP+znauLDGAi+h6i9YnaMkITlfIoiM4RYyX3nki306bTHsr/0okiIvIc7BJhQTbOAIZVocccFUw==",
"type": "Package",
"files": [
"[Content_Types].xml",
"_rels/.rels",
"lib/net20/Newtonsoft.Json.dll",
"lib/net20/Newtonsoft.Json.xml",
"lib/net35/Newtonsoft.Json.dll",
"lib/net35/Newtonsoft.Json.xml",
"lib/net40/Newtonsoft.Json.dll",
"lib/net40/Newtonsoft.Json.xml",
"lib/net45/Newtonsoft.Json.dll",
"lib/net45/Newtonsoft.Json.xml",
"lib/netcore45/Newtonsoft.Json.dll",
"lib/netcore45/Newtonsoft.Json.xml",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.xml",
"Newtonsoft.Json.nuspec",
"package/services/metadata/core-properties/87a0a4e28d50417ea282e20f81bc6477.psmdcp",
"tools/install.ps1"
]
},
"System.AppContext/4.0.0": {
"sha512": "gUoYgAWDC3+xhKeU5KSLbYDhTdBYk9GssrMSCcWUADzOglW+s0AmwVhOUGt2tL5xUl7ZXoYTPdA88zCgKrlG0A==",
"type": "Package",
......@@ -1197,7 +1164,6 @@
"projectFileDependencyGroups": {
"": [
"Microsoft.Composition >= 1.0.27",
"Newtonsoft.Json >= 6.0.4",
"System.Collections >= 4.0.10",
"System.Diagnostics.Debug >= 4.0.10",
"System.Globalization >= 4.0.10",
......
......@@ -28,14 +28,6 @@
"lib/net45/_._": {}
}
},
"Newtonsoft.Json/6.0.4": {
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
},
"System.AppContext/4.0.0": {
"dependencies": {
"System.Runtime": "[4.0.0, )"
......@@ -295,14 +287,6 @@
"lib/net45/_._": {}
}
},
"Newtonsoft.Json/6.0.4": {
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
},
"System.AppContext/4.0.0": {
"dependencies": {
"System.Runtime": "[4.0.0, )"
......@@ -652,31 +636,6 @@
"runtimes/aot/lib/netcore50/System.Xml.Serialization.dll"
]
},
"Newtonsoft.Json/6.0.4": {
"sha512": "FyQLmEpjsCrEP+znauLDGAi+h6i9YnaMkITlfIoiM4RYyX3nki306bTHsr/0okiIvIc7BJhQTbOAIZVocccFUw==",
"type": "Package",
"files": [
"[Content_Types].xml",
"_rels/.rels",
"lib/net20/Newtonsoft.Json.dll",
"lib/net20/Newtonsoft.Json.xml",
"lib/net35/Newtonsoft.Json.dll",
"lib/net35/Newtonsoft.Json.xml",
"lib/net40/Newtonsoft.Json.dll",
"lib/net40/Newtonsoft.Json.xml",
"lib/net45/Newtonsoft.Json.dll",
"lib/net45/Newtonsoft.Json.xml",
"lib/netcore45/Newtonsoft.Json.dll",
"lib/netcore45/Newtonsoft.Json.xml",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.xml",
"Newtonsoft.Json.nuspec",
"package/services/metadata/core-properties/87a0a4e28d50417ea282e20f81bc6477.psmdcp",
"tools/install.ps1"
]
},
"System.AppContext/4.0.0": {
"sha512": "gUoYgAWDC3+xhKeU5KSLbYDhTdBYk9GssrMSCcWUADzOglW+s0AmwVhOUGt2tL5xUl7ZXoYTPdA88zCgKrlG0A==",
"type": "Package",
......
......@@ -104,7 +104,6 @@
<ItemGroup>
<Compile Include="AbstractInteractiveHostTests.cs" />
<Compile Include="InteractiveHostTests.cs" />
<Compile Include="NuGetPackageResolverTests.cs" />
<Compile Include="StressTests.cs" />
<Compile Include="SynchronizedTextWriter.cs" />
</ItemGroup>
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.Interactive;
using Microsoft.CodeAnalysis.Test.Utilities;
using Roslyn.Test.Utilities;
using Roslyn.Utilities;
using System;
using System.IO;
using System.Text;
using Xunit;
namespace Microsoft.CodeAnalysis.UnitTests.Interactive
{
public class NuGetPackageResolverTests : TestBase
{
/// <summary>
/// Valid reference.
/// </summary>
[ConditionalFact(typeof(WindowsOnly))]
public void ResolveReference()
{
var expectedProjectJson =
@"{
""dependencies"": {
""A.B.C"": ""1.2""
},
""frameworks"": {
""net46"": {}
}
}";
var expectedConfig =
@"<?xml version=""1.0"" encoding=""utf-8""?>
<configuration>
<packageRestore>
<add key=""enabled"" value=""True"" />
<add key=""automatic"" value=""False"" />
</packageRestore>
<packageSources/>
</configuration>";
var actualProjectLockJson =
@"{
""locked"": false,
""version"": 1,
""targets"": {
"".NETFramework,Version=v4.5"": { },
"".NETFramework,Version=v4.6"": {
""System.Collections/4.0.10"": {
""dependencies"": {
""System.Runtime"": """"
},
""compile"": {
""ref/dotnet/System.Runtime.dll"": {}
},
""runtime"": {
""ref/dotnet/System.Collections.dll"": {}
}
},
""System.Diagnostics.Debug/4.0.10"": {
""dependencies"": {
""System.Runtime"": """"
},
},
""System.Runtime/4.0.0"": {
""runtime"": {
""ref/dotnet/_._"": {}
}
},
""System.IO/4.0.10"": {
""dependencies"": {},
""runtime"": {
""ref/dotnet/System.Runtime.dll"": {},
""ref/dotnet/System.IO.dll"": {}
}
}
}
}
}";
using (var directory = new DisposableDirectory(Temp))
{
var packagesDirectory = directory.Path;
var resolver = new NuGetPackageResolverImpl(
packagesDirectory,
startInfo =>
{
// Verify arguments.
var arguments = startInfo.Arguments.Split('"');
Assert.Equal(7, arguments.Length);
Assert.Equal("restore ", arguments[0]);
Assert.Equal("project.json", PathUtilities.GetFileName(arguments[1]));
Assert.Equal(" -ConfigFile ", arguments[2]);
Assert.Equal("nuget.config", PathUtilities.GetFileName(arguments[3]));
Assert.Equal(" -PackagesDirectory ", arguments[4]);
Assert.Equal(packagesDirectory, arguments[5]);
Assert.Equal("", arguments[6]);
// Verify project.json contents.
var projectJsonPath = arguments[1];
var actualProjectJson = File.ReadAllText(projectJsonPath);
Assert.Equal(expectedProjectJson, actualProjectJson);
// Verify config file contents.
var configPath = arguments[3];
var actualConfig = File.ReadAllText(configPath);
Assert.Equal(expectedConfig, actualConfig);
// Generate project.lock.json.
var projectLockJsonPath = PathUtilities.CombineAbsoluteAndRelativePaths(PathUtilities.GetDirectoryName(projectJsonPath), "project.lock.json");
using (var writer = new StreamWriter(projectLockJsonPath))
{
writer.Write(actualProjectLockJson);
}
});
var actualPaths = resolver.ResolveNuGetPackage("A.B.C", "1.2");
AssertEx.SetEqual(actualPaths,
PathUtilities.CombineAbsoluteAndRelativePaths(packagesDirectory, PathUtilities.CombinePossiblyRelativeAndRelativePaths("System.Collections/4.0.10", "ref/dotnet/System.Collections.dll")),
PathUtilities.CombineAbsoluteAndRelativePaths(packagesDirectory, PathUtilities.CombinePossiblyRelativeAndRelativePaths("System.IO/4.0.10", "ref/dotnet/System.Runtime.dll")),
PathUtilities.CombineAbsoluteAndRelativePaths(packagesDirectory, PathUtilities.CombinePossiblyRelativeAndRelativePaths("System.IO/4.0.10", "ref/dotnet/System.IO.dll")));
}
}
/// <summary>
/// Expected exception thrown during restore.
/// </summary>
[ConditionalFact(typeof(WindowsOnly))]
public void HandledException()
{
using (var directory = new DisposableDirectory(Temp))
{
bool restored = false;
var resolver = new NuGetPackageResolverImpl(directory.Path, startInfo => { restored = true; throw new IOException(); });
var actualPaths = resolver.ResolveNuGetPackage("A.B.C", "1.2");
Assert.True(actualPaths.IsEmpty);
Assert.True(restored);
}
}
/// <summary>
/// Unexpected exception thrown during restore.
/// </summary>
[ConditionalFact(typeof(WindowsOnly))]
public void UnhandledException()
{
using (var directory = new DisposableDirectory(Temp))
{
bool restored = false;
var resolver = new NuGetPackageResolverImpl(directory.Path, startInfo => { restored = true; throw new InvalidOperationException(); });
Assert.Throws<InvalidOperationException>(() => resolver.ResolveNuGetPackage("A.B.C", "1.2"));
Assert.True(restored);
}
}
[ConditionalFact(typeof(WindowsOnly))]
public void ParsePackageNameAndVersion()
{
ParseInvalidPackageReference("A");
ParseInvalidPackageReference("A/1");
ParseInvalidPackageReference("nuget");
ParseInvalidPackageReference("nuget:");
ParseInvalidPackageReference("NUGET:");
ParseInvalidPackageReference("nugetA/1");
ParseValidPackageReference("nuget:A", "A", "");
ParseValidPackageReference("nuget:A.B", "A.B", "");
ParseValidPackageReference("nuget: ", " ", "");
ParseInvalidPackageReference("nuget:A/");
ParseInvalidPackageReference("nuget:A//1.0");
ParseInvalidPackageReference("nuget:/1.0.0");
ParseInvalidPackageReference("nuget:A/B/2.0.0");
ParseValidPackageReference("nuget::nuget/1", ":nuget", "1");
ParseValidPackageReference("nuget:A/1", "A", "1");
ParseValidPackageReference("nuget:A.B/1.0.0", "A.B", "1.0.0");
ParseValidPackageReference("nuget:A/B.C", "A", "B.C");
ParseValidPackageReference("nuget: /1", " ", "1");
ParseValidPackageReference("nuget:A\t/\n1.0\r ", "A\t", "\n1.0\r ");
}
private static void ParseValidPackageReference(string reference, string expectedName, string expectedVersion)
{
string name;
string version;
Assert.True(NuGetPackageResolverImpl.TryParsePackageReference(reference, out name, out version));
Assert.Equal(expectedName, name);
Assert.Equal(expectedVersion, version);
}
private static void ParseInvalidPackageReference(string reference)
{
string name;
string version;
Assert.False(NuGetPackageResolverImpl.TryParsePackageReference(reference, out name, out version));
Assert.Null(name);
Assert.Null(version);
}
[ConditionalFact(typeof(WindowsOnly))]
public void WriteProjectJson()
{
WriteProjectJsonPackageReference("A.B", "4.0.1",
@"{
""dependencies"": {
""A.B"": ""4.0.1""
},
""frameworks"": {
""net46"": {}
}
}");
WriteProjectJsonPackageReference("A", "",
@"{
""dependencies"": {
""A"": """"
},
""frameworks"": {
""net46"": {}
}
}");
WriteProjectJsonPackageReference("\n\t", "\"'",
@"{
""dependencies"": {
""\n\t"": ""\""'""
},
""frameworks"": {
""net46"": {}
}
}");
}
private static void WriteProjectJsonPackageReference(string packageName, string packageVersion, string expectedJson)
{
var builder = new StringBuilder();
using (var writer = new StringWriter(builder))
{
NuGetPackageResolverImpl.WriteProjectJson(writer, packageName, packageVersion);
}
var actualJson = builder.ToString();
Assert.Equal(expectedJson, actualJson);
}
}
}
......@@ -44,25 +44,6 @@
"lib/net45/_._": {}
}
},
"Microsoft.VisualBasic/10.0.0": {
"frameworkAssemblies": [
"Microsoft.VisualBasic"
],
"compile": {
"ref/net45/_._": {}
},
"runtime": {
"lib/net45/_._": {}
}
},
"Newtonsoft.Json/6.0.4": {
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
},
"System.AppContext/4.0.0": {
"dependencies": {
"System.Runtime": "[4.0.0, )"
......@@ -445,62 +426,6 @@
"runtimes/aot/lib/netcore50/System.Xml.Serialization.dll"
]
},
"Microsoft.VisualBasic/10.0.0": {
"sha512": "5BEm2/HAVd97whRlCChU7rmSh/9cwGlZ/NTNe3Jl07zuPWfKQq5TUvVNUmdvmEe8QRecJLZ4/e7WF1i1O8V42g==",
"type": "Package",
"files": [
"[Content_Types].xml",
"_rels/.rels",
"lib/dotnet/Microsoft.VisualBasic.dll",
"lib/net45/_._",
"lib/netcore50/Microsoft.VisualBasic.dll",
"lib/win8/_._",
"lib/wpa81/_._",
"Microsoft.VisualBasic.nuspec",
"package/services/metadata/core-properties/5dbd3a7042354092a8b352b655cf4376.psmdcp",
"ref/dotnet/de/Microsoft.VisualBasic.xml",
"ref/dotnet/es/Microsoft.VisualBasic.xml",
"ref/dotnet/fr/Microsoft.VisualBasic.xml",
"ref/dotnet/it/Microsoft.VisualBasic.xml",
"ref/dotnet/ja/Microsoft.VisualBasic.xml",
"ref/dotnet/ko/Microsoft.VisualBasic.xml",
"ref/dotnet/Microsoft.VisualBasic.dll",
"ref/dotnet/Microsoft.VisualBasic.xml",
"ref/dotnet/ru/Microsoft.VisualBasic.xml",
"ref/dotnet/zh-hans/Microsoft.VisualBasic.xml",
"ref/dotnet/zh-hant/Microsoft.VisualBasic.xml",
"ref/net45/_._",
"ref/netcore50/Microsoft.VisualBasic.dll",
"ref/netcore50/Microsoft.VisualBasic.xml",
"ref/win8/_._",
"ref/wpa81/_._"
]
},
"Newtonsoft.Json/6.0.4": {
"sha512": "FyQLmEpjsCrEP+znauLDGAi+h6i9YnaMkITlfIoiM4RYyX3nki306bTHsr/0okiIvIc7BJhQTbOAIZVocccFUw==",
"type": "Package",
"files": [
"[Content_Types].xml",
"_rels/.rels",
"lib/net20/Newtonsoft.Json.dll",
"lib/net20/Newtonsoft.Json.xml",
"lib/net35/Newtonsoft.Json.dll",
"lib/net35/Newtonsoft.Json.xml",
"lib/net40/Newtonsoft.Json.dll",
"lib/net40/Newtonsoft.Json.xml",
"lib/net45/Newtonsoft.Json.dll",
"lib/net45/Newtonsoft.Json.xml",
"lib/netcore45/Newtonsoft.Json.dll",
"lib/netcore45/Newtonsoft.Json.xml",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.xml",
"Newtonsoft.Json.nuspec",
"package/services/metadata/core-properties/87a0a4e28d50417ea282e20f81bc6477.psmdcp",
"tools/install.ps1"
]
},
"System.AppContext/4.0.0": {
"sha512": "gUoYgAWDC3+xhKeU5KSLbYDhTdBYk9GssrMSCcWUADzOglW+s0AmwVhOUGt2tL5xUl7ZXoYTPdA88zCgKrlG0A==",
"type": "Package",
......
......@@ -21,14 +21,6 @@
"lib/net45/_._": {}
}
},
"Newtonsoft.Json/6.0.4": {
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
},
"System.AppContext/4.0.0": {
"dependencies": {
"System.Runtime": "[4.0.0, )"
......@@ -526,31 +518,6 @@
"runtimes/aot/lib/netcore50/System.Xml.Serialization.dll"
]
},
"Newtonsoft.Json/6.0.4": {
"sha512": "FyQLmEpjsCrEP+znauLDGAi+h6i9YnaMkITlfIoiM4RYyX3nki306bTHsr/0okiIvIc7BJhQTbOAIZVocccFUw==",
"type": "Package",
"files": [
"[Content_Types].xml",
"_rels/.rels",
"lib/net20/Newtonsoft.Json.dll",
"lib/net20/Newtonsoft.Json.xml",
"lib/net35/Newtonsoft.Json.dll",
"lib/net35/Newtonsoft.Json.xml",
"lib/net40/Newtonsoft.Json.dll",
"lib/net40/Newtonsoft.Json.xml",
"lib/net45/Newtonsoft.Json.dll",
"lib/net45/Newtonsoft.Json.xml",
"lib/netcore45/Newtonsoft.Json.dll",
"lib/netcore45/Newtonsoft.Json.xml",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.xml",
"Newtonsoft.Json.nuspec",
"package/services/metadata/core-properties/87a0a4e28d50417ea282e20f81bc6477.psmdcp",
"tools/install.ps1"
]
},
"System.AppContext/4.0.0": {
"sha512": "gUoYgAWDC3+xhKeU5KSLbYDhTdBYk9GssrMSCcWUADzOglW+s0AmwVhOUGt2tL5xUl7ZXoYTPdA88zCgKrlG0A==",
"type": "Package",
......
......@@ -56,14 +56,6 @@
"ref/dotnet/System.Xml.Serialization.dll": {}
}
},
"Newtonsoft.Json/6.0.4": {
"compile": {
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll": {}
}
},
"System.AppContext/4.0.0": {
"dependencies": {
"System.Runtime": "[4.0.0, )"
......@@ -693,31 +685,6 @@
"runtimes/aot/lib/netcore50/System.Xml.Serialization.dll"
]
},
"Newtonsoft.Json/6.0.4": {
"sha512": "FyQLmEpjsCrEP+znauLDGAi+h6i9YnaMkITlfIoiM4RYyX3nki306bTHsr/0okiIvIc7BJhQTbOAIZVocccFUw==",
"type": "Package",
"files": [
"[Content_Types].xml",
"_rels/.rels",
"lib/net20/Newtonsoft.Json.dll",
"lib/net20/Newtonsoft.Json.xml",
"lib/net35/Newtonsoft.Json.dll",
"lib/net35/Newtonsoft.Json.xml",
"lib/net40/Newtonsoft.Json.dll",
"lib/net40/Newtonsoft.Json.xml",
"lib/net45/Newtonsoft.Json.dll",
"lib/net45/Newtonsoft.Json.xml",
"lib/netcore45/Newtonsoft.Json.dll",
"lib/netcore45/Newtonsoft.Json.xml",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.xml",
"Newtonsoft.Json.nuspec",
"package/services/metadata/core-properties/87a0a4e28d50417ea282e20f81bc6477.psmdcp",
"tools/install.ps1"
]
},
"System.AppContext/4.0.0": {
"sha512": "gUoYgAWDC3+xhKeU5KSLbYDhTdBYk9GssrMSCcWUADzOglW+s0AmwVhOUGt2tL5xUl7ZXoYTPdA88zCgKrlG0A==",
"type": "Package",
......
......@@ -21,14 +21,6 @@
"lib/net45/_._": {}
}
},
"Newtonsoft.Json/6.0.4": {
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
},
"System.AppContext/4.0.0": {
"dependencies": {
"System.Runtime": "[4.0.0, )"
......@@ -493,31 +485,6 @@
"runtimes/aot/lib/netcore50/System.Xml.Serialization.dll"
]
},
"Newtonsoft.Json/6.0.4": {
"sha512": "FyQLmEpjsCrEP+znauLDGAi+h6i9YnaMkITlfIoiM4RYyX3nki306bTHsr/0okiIvIc7BJhQTbOAIZVocccFUw==",
"type": "Package",
"files": [
"[Content_Types].xml",
"_rels/.rels",
"lib/net20/Newtonsoft.Json.dll",
"lib/net20/Newtonsoft.Json.xml",
"lib/net35/Newtonsoft.Json.dll",
"lib/net35/Newtonsoft.Json.xml",
"lib/net40/Newtonsoft.Json.dll",
"lib/net40/Newtonsoft.Json.xml",
"lib/net45/Newtonsoft.Json.dll",
"lib/net45/Newtonsoft.Json.xml",
"lib/netcore45/Newtonsoft.Json.dll",
"lib/netcore45/Newtonsoft.Json.xml",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.xml",
"Newtonsoft.Json.nuspec",
"package/services/metadata/core-properties/87a0a4e28d50417ea282e20f81bc6477.psmdcp",
"tools/install.ps1"
]
},
"System.AppContext/4.0.0": {
"sha512": "gUoYgAWDC3+xhKeU5KSLbYDhTdBYk9GssrMSCcWUADzOglW+s0AmwVhOUGt2tL5xUl7ZXoYTPdA88zCgKrlG0A==",
"type": "Package",
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis.Scripting.Hosting;
using Roslyn.Test.Utilities;
using Xunit;
namespace Microsoft.CodeAnalysis.Scripting.Test
{
public class NuGetPackageResolverTests : TestBase
{
[Fact]
public void ParsePackageNameAndVersion()
{
ParseInvalidPackageReference("A");
ParseInvalidPackageReference("A/1");
ParseInvalidPackageReference("nuget");
ParseInvalidPackageReference("nuget:");
ParseInvalidPackageReference("NUGET:");
ParseInvalidPackageReference("nugetA/1");
ParseValidPackageReference("nuget:A", "A", "");
ParseValidPackageReference("nuget:A.B", "A.B", "");
ParseValidPackageReference("nuget: ", " ", "");
ParseInvalidPackageReference("nuget:A/");
ParseInvalidPackageReference("nuget:A//1.0");
ParseInvalidPackageReference("nuget:/1.0.0");
ParseInvalidPackageReference("nuget:A/B/2.0.0");
ParseValidPackageReference("nuget::nuget/1", ":nuget", "1");
ParseValidPackageReference("nuget:A/1", "A", "1");
ParseValidPackageReference("nuget:A.B/1.0.0", "A.B", "1.0.0");
ParseValidPackageReference("nuget:A/B.C", "A", "B.C");
ParseValidPackageReference("nuget: /1", " ", "1");
ParseValidPackageReference("nuget:A\t/\n1.0\r ", "A\t", "\n1.0\r ");
}
private static void ParseValidPackageReference(string reference, string expectedName, string expectedVersion)
{
string name;
string version;
Assert.True(NuGetPackageResolver.TryParsePackageReference(reference, out name, out version));
Assert.Equal(expectedName, name);
Assert.Equal(expectedVersion, version);
}
private static void ParseInvalidPackageReference(string reference)
{
string name;
string version;
Assert.False(NuGetPackageResolver.TryParsePackageReference(reference, out name, out version));
Assert.Null(name);
Assert.Null(version);
}
}
}
......@@ -56,6 +56,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
</PropertyGroup>
<ItemGroup>
<Compile Include="NuGetPackageResolverTests.cs" />
<Compile Include="ObjectFormatterTestBase.cs" />
<Compile Include="ObjectFormatterTests.Fixtures.cs" />
<Compile Include="RedirectedOutput.cs" />
......@@ -79,4 +80,4 @@
<Import Project="..\..\..\build\Targets\VSL.Imports.targets" />
<Import Project="..\..\..\build\Targets\Roslyn.Toolsets.Xunit.targets" />
</ImportGroup>
</Project>
</Project>
\ No newline at end of file
......@@ -56,14 +56,6 @@
"ref/dotnet/System.Xml.Serialization.dll": {}
}
},
"Newtonsoft.Json/6.0.4": {
"compile": {
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll": {}
}
},
"System.AppContext/4.0.0": {
"dependencies": {
"System.Runtime": "[4.0.0, )"
......@@ -693,31 +685,6 @@
"runtimes/aot/lib/netcore50/System.Xml.Serialization.dll"
]
},
"Newtonsoft.Json/6.0.4": {
"sha512": "FyQLmEpjsCrEP+znauLDGAi+h6i9YnaMkITlfIoiM4RYyX3nki306bTHsr/0okiIvIc7BJhQTbOAIZVocccFUw==",
"type": "Package",
"files": [
"[Content_Types].xml",
"_rels/.rels",
"lib/net20/Newtonsoft.Json.dll",
"lib/net20/Newtonsoft.Json.xml",
"lib/net35/Newtonsoft.Json.dll",
"lib/net35/Newtonsoft.Json.xml",
"lib/net40/Newtonsoft.Json.dll",
"lib/net40/Newtonsoft.Json.xml",
"lib/net45/Newtonsoft.Json.dll",
"lib/net45/Newtonsoft.Json.xml",
"lib/netcore45/Newtonsoft.Json.dll",
"lib/netcore45/Newtonsoft.Json.xml",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.xml",
"Newtonsoft.Json.nuspec",
"package/services/metadata/core-properties/87a0a4e28d50417ea282e20f81bc6477.psmdcp",
"tools/install.ps1"
]
},
"System.AppContext/4.0.0": {
"sha512": "gUoYgAWDC3+xhKeU5KSLbYDhTdBYk9GssrMSCcWUADzOglW+s0AmwVhOUGt2tL5xUl7ZXoYTPdA88zCgKrlG0A==",
"type": "Package",
......
......@@ -32,14 +32,6 @@
"lib/net45/_._": {}
}
},
"Newtonsoft.Json/6.0.4": {
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
},
"System.AppContext/4.0.0": {
"dependencies": {
"System.Runtime": "[4.0.0, )"
......@@ -535,31 +527,6 @@
"ref/wpa81/_._"
]
},
"Newtonsoft.Json/6.0.4": {
"sha512": "FyQLmEpjsCrEP+znauLDGAi+h6i9YnaMkITlfIoiM4RYyX3nki306bTHsr/0okiIvIc7BJhQTbOAIZVocccFUw==",
"type": "Package",
"files": [
"[Content_Types].xml",
"_rels/.rels",
"lib/net20/Newtonsoft.Json.dll",
"lib/net20/Newtonsoft.Json.xml",
"lib/net35/Newtonsoft.Json.dll",
"lib/net35/Newtonsoft.Json.xml",
"lib/net40/Newtonsoft.Json.dll",
"lib/net40/Newtonsoft.Json.xml",
"lib/net45/Newtonsoft.Json.dll",
"lib/net45/Newtonsoft.Json.xml",
"lib/netcore45/Newtonsoft.Json.dll",
"lib/netcore45/Newtonsoft.Json.xml",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.xml",
"Newtonsoft.Json.nuspec",
"package/services/metadata/core-properties/87a0a4e28d50417ea282e20f81bc6477.psmdcp",
"tools/install.ps1"
]
},
"System.AppContext/4.0.0": {
"sha512": "gUoYgAWDC3+xhKeU5KSLbYDhTdBYk9GssrMSCcWUADzOglW+s0AmwVhOUGt2tL5xUl7ZXoYTPdA88zCgKrlG0A==",
"type": "Package",
......
......@@ -82,14 +82,6 @@
"lib/dotnet/Microsoft.VisualBasic.dll": {}
}
},
"Newtonsoft.Json/6.0.4": {
"compile": {
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll": {}
}
},
"System.AppContext/4.0.0": {
"dependencies": {
"System.Runtime": "[4.0.0, )"
......@@ -750,31 +742,6 @@
"ref/wpa81/_._"
]
},
"Newtonsoft.Json/6.0.4": {
"sha512": "FyQLmEpjsCrEP+znauLDGAi+h6i9YnaMkITlfIoiM4RYyX3nki306bTHsr/0okiIvIc7BJhQTbOAIZVocccFUw==",
"type": "Package",
"files": [
"[Content_Types].xml",
"_rels/.rels",
"lib/net20/Newtonsoft.Json.dll",
"lib/net20/Newtonsoft.Json.xml",
"lib/net35/Newtonsoft.Json.dll",
"lib/net35/Newtonsoft.Json.xml",
"lib/net40/Newtonsoft.Json.dll",
"lib/net40/Newtonsoft.Json.xml",
"lib/net45/Newtonsoft.Json.dll",
"lib/net45/Newtonsoft.Json.xml",
"lib/netcore45/Newtonsoft.Json.dll",
"lib/netcore45/Newtonsoft.Json.xml",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.xml",
"Newtonsoft.Json.nuspec",
"package/services/metadata/core-properties/87a0a4e28d50417ea282e20f81bc6477.psmdcp",
"tools/install.ps1"
]
},
"System.AppContext/4.0.0": {
"sha512": "gUoYgAWDC3+xhKeU5KSLbYDhTdBYk9GssrMSCcWUADzOglW+s0AmwVhOUGt2tL5xUl7ZXoYTPdA88zCgKrlG0A==",
"type": "Package",
......
......@@ -30,14 +30,6 @@
"ref/dotnet/System.Xml.Serialization.dll": {}
}
},
"Newtonsoft.Json/6.0.4": {
"compile": {
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll": {}
}
},
"System.AppContext/4.0.0": {
"dependencies": {
"System.Runtime": "[4.0.0, )"
......@@ -573,31 +565,6 @@
"runtimes/aot/lib/netcore50/System.Xml.Serialization.dll"
]
},
"Newtonsoft.Json/6.0.4": {
"sha512": "FyQLmEpjsCrEP+znauLDGAi+h6i9YnaMkITlfIoiM4RYyX3nki306bTHsr/0okiIvIc7BJhQTbOAIZVocccFUw==",
"type": "Package",
"files": [
"[Content_Types].xml",
"_rels/.rels",
"lib/net20/Newtonsoft.Json.dll",
"lib/net20/Newtonsoft.Json.xml",
"lib/net35/Newtonsoft.Json.dll",
"lib/net35/Newtonsoft.Json.xml",
"lib/net40/Newtonsoft.Json.dll",
"lib/net40/Newtonsoft.Json.xml",
"lib/net45/Newtonsoft.Json.dll",
"lib/net45/Newtonsoft.Json.xml",
"lib/netcore45/Newtonsoft.Json.dll",
"lib/netcore45/Newtonsoft.Json.xml",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.xml",
"Newtonsoft.Json.nuspec",
"package/services/metadata/core-properties/87a0a4e28d50417ea282e20f81bc6477.psmdcp",
"tools/install.ps1"
]
},
"System.AppContext/4.0.0": {
"sha512": "gUoYgAWDC3+xhKeU5KSLbYDhTdBYk9GssrMSCcWUADzOglW+s0AmwVhOUGt2tL5xUl7ZXoYTPdA88zCgKrlG0A==",
"type": "Package",
......
{
"dependencies": {
"Microsoft.NETCore.Platforms": "1.0.0",
"Newtonsoft.Json": "6.0.4",
"System.Collections": "4.0.10",
"System.Collections.Immutable": "1.1.36",
"System.Console": "4.0.0-beta-23123",
......
......@@ -4,14 +4,6 @@
"targets": {
".NETFramework,Version=v4.6": {
"Microsoft.NETCore.Platforms/1.0.0": {},
"Newtonsoft.Json/6.0.4": {
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
},
"System.AppContext/4.0.0": {
"dependencies": {
"System.Runtime": "[4.0.0, )"
......@@ -303,14 +295,6 @@
},
".NETFramework,Version=v4.6/win-": {
"Microsoft.NETCore.Platforms/1.0.0": {},
"Newtonsoft.Json/6.0.4": {
"compile": {
"lib/net45/Newtonsoft.Json.dll": {}
},
"runtime": {
"lib/net45/Newtonsoft.Json.dll": {}
}
},
"System.AppContext/4.0.0": {
"dependencies": {
"System.Runtime": "[4.0.0, )"
......@@ -613,31 +597,6 @@
"runtime.json"
]
},
"Newtonsoft.Json/6.0.4": {
"sha512": "FyQLmEpjsCrEP+znauLDGAi+h6i9YnaMkITlfIoiM4RYyX3nki306bTHsr/0okiIvIc7BJhQTbOAIZVocccFUw==",
"type": "Package",
"files": [
"[Content_Types].xml",
"_rels/.rels",
"lib/net20/Newtonsoft.Json.dll",
"lib/net20/Newtonsoft.Json.xml",
"lib/net35/Newtonsoft.Json.dll",
"lib/net35/Newtonsoft.Json.xml",
"lib/net40/Newtonsoft.Json.dll",
"lib/net40/Newtonsoft.Json.xml",
"lib/net45/Newtonsoft.Json.dll",
"lib/net45/Newtonsoft.Json.xml",
"lib/netcore45/Newtonsoft.Json.dll",
"lib/netcore45/Newtonsoft.Json.xml",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net40+sl5+wp80+win8+wpa81/Newtonsoft.Json.xml",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.dll",
"lib/portable-net45+wp80+win8+wpa81/Newtonsoft.Json.xml",
"Newtonsoft.Json.nuspec",
"package/services/metadata/core-properties/87a0a4e28d50417ea282e20f81bc6477.psmdcp",
"tools/install.ps1"
]
},
"System.AppContext/4.0.0": {
"sha512": "gUoYgAWDC3+xhKeU5KSLbYDhTdBYk9GssrMSCcWUADzOglW+s0AmwVhOUGt2tL5xUl7ZXoYTPdA88zCgKrlG0A==",
"type": "Package",
......@@ -1490,7 +1449,6 @@
"projectFileDependencyGroups": {
"": [
"Microsoft.NETCore.Platforms >= 1.0.0",
"Newtonsoft.Json >= 6.0.4",
"System.AppContext >= 4.0.0",
"System.Collections >= 4.0.10",
"System.Collections.Immutable >= 1.1.36",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册