Skip to content
This repository was archived by the owner on Dec 18, 2017. It is now read-only.

Commit 3e49b08

Browse files
committed
fix bug with lifting packages in publish
1 parent 8d5b23a commit 3e49b08

File tree

3 files changed

+74
-38
lines changed

3 files changed

+74
-38
lines changed

misc/PublishRuntimeDependency/Program.cs

Lines changed: 66 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,69 @@
11
using System;
2+
using System.Data.SqlClient;
23
using System.IO;
4+
using System.Net.NetworkInformation;
35
using System.Net.Security;
46
using System.Net.Sockets;
7+
using System.Net.WebSockets;
8+
using System.Reflection;
59
using System.Text;
10+
using System.Threading;
611

712
namespace PublishRuntimeDependency
813
{
914
public class Program
1015
{
1116
public void Main(string[] args)
1217
{
13-
if (args.Length < 1)
14-
{
15-
args = new[] { "https://www.microsoft.com" };
16-
}
18+
RunTest("System.Net.Security", TestSslStream);
19+
RunTest("System.Net.NetworkInformation", TestNetworkInformation);
20+
RunTest("System.Net.WebSockets.Client", TestWebSockets);
21+
RunTest("System.Data.SqlClient", TestSqlClient);
22+
RunTest("System.Reflection.DispatchProxy", TestDispatchProxy);
23+
}
1724

18-
Console.WriteLine("=== Testing with raw Stream ===");
19-
try
25+
public interface ITestInterface
26+
{
27+
void DoTheThing();
28+
}
29+
public class TestProxy : DispatchProxy
30+
{
31+
public bool WasCalled { get; private set; }
32+
33+
protected override object Invoke(MethodInfo targetMethod, object[] args)
2034
{
21-
TestStream(args[0]);
35+
WasCalled = true;
36+
Console.WriteLine($"Intercepted: {targetMethod.Name} with dispatch proxy");
37+
return null;
2238
}
23-
catch (Exception ex)
39+
}
40+
41+
private void TestDispatchProxy()
42+
{
43+
var proxy = DispatchProxy.Create<ITestInterface, TestProxy>();
44+
proxy.DoTheThing();
45+
46+
if (!((TestProxy)proxy).WasCalled)
2447
{
25-
Console.WriteLine("FAILED:");
26-
Console.WriteLine(ex.ToString());
48+
throw new Exception("The proxy was not called!");
2749
}
50+
Console.WriteLine("The proxy was called");
51+
}
2852

53+
private void TestSqlClient()
54+
{
55+
// Don't want to take a dependency on Sql Server so we just force loading by constructing a type
56+
var con = new SqlConnection();
57+
Console.WriteLine("Successfully loaded System.Data.SqlClient");
58+
}
59+
60+
private void RunTest(string name, Action act)
61+
{
2962
Console.WriteLine();
30-
Console.WriteLine("=== Testing with StreamReader ===");
63+
Console.WriteLine($"=== Testing {name} ===");
3164
try
3265
{
33-
TestStreamReader(args[0]);
66+
act();
3467
}
3568
catch (Exception ex)
3669
{
@@ -39,33 +72,34 @@ public void Main(string[] args)
3972
}
4073
}
4174

42-
public void TestStreamReader(string urlStr)
75+
private void TestWebSockets()
4376
{
44-
// Make a simple HTTP request
45-
var url = new Uri(urlStr);
77+
var socket = new ClientWebSocket();
78+
Console.WriteLine("Connecting");
79+
socket.ConnectAsync(new Uri("wss://echo.websocket.org"), CancellationToken.None).Wait();
4680

47-
var socket = new Socket(SocketType.Stream, ProtocolType.Tcp);
48-
socket.Connect(url.Host, url.Port);
81+
Console.WriteLine("Sending");
82+
socket.SendAsync(new ArraySegment<byte>(Encoding.UTF8.GetBytes("Hello")), WebSocketMessageType.Text, true, CancellationToken.None).Wait();
4983

50-
using (var stream = GetStream(socket, url))
51-
{
52-
// Send the request
53-
var request = $"GET {url.PathAndQuery} HTTP/1.1\r\nHost: {url.Host}\r\nConnection: close\r\n\r\n";
54-
var buffer = Encoding.UTF8.GetBytes(request);
55-
stream.Write(buffer, 0, buffer.Length);
84+
var buffer = new byte[1024];
85+
Console.WriteLine("Receiving");
86+
var result = socket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None).Result;
5687

57-
// Read the response
58-
using (var reader = new StreamReader(stream, Encoding.UTF8))
59-
{
60-
Console.WriteLine(reader.ReadToEnd());
61-
}
88+
Console.WriteLine($"Recieved: {Encoding.UTF8.GetString(buffer, 0, result.Count)}");
89+
}
90+
91+
private void TestNetworkInformation()
92+
{
93+
foreach (var iface in NetworkInterface.GetAllNetworkInterfaces())
94+
{
95+
Console.WriteLine($"Network Interface: {iface.Id} {iface.Name} ({iface.NetworkInterfaceType})");
6296
}
6397
}
6498

65-
public void TestStream(string urlStr)
99+
public void TestSslStream()
66100
{
67101
// Make a simple HTTP request
68-
var url = new Uri(urlStr);
102+
var url = new Uri("https://www.microsoft.com");
69103

70104
var socket = new Socket(SocketType.Stream, ProtocolType.Tcp);
71105
socket.Connect(url.Host, url.Port);
@@ -78,13 +112,9 @@ public void TestStream(string urlStr)
78112
stream.Write(buffer, 0, buffer.Length);
79113

80114
// Read the response
81-
byte[] readbuffer = new byte[1024];
82-
int read = 0;
83-
Console.WriteLine("Response:");
84-
while ((read = stream.Read(readbuffer, 0, readbuffer.Length)) != 0)
115+
using (var reader = new StreamReader(stream, Encoding.UTF8))
85116
{
86-
var converted = Encoding.UTF8.GetString(readbuffer, 0, read);
87-
Console.Write(converted);
117+
Console.WriteLine(reader.ReadToEnd());
88118
}
89119
}
90120
}

misc/PublishRuntimeDependency/project.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
{
22
"dependencies": {
3+
"Microsoft.NETCore.Platforms": "1.0.1-beta-23516",
34
"System.Console": "4.0.0-beta-23516",
45
"System.Net.Sockets": "4.1.0-beta-23516",
5-
"System.Net.Security": "4.0.0-beta-23516"
6+
"System.Net.Security": "4.0.0-beta-23516",
7+
"System.Runtime": "4.0.21-beta-23516",
8+
"System.Net.NetworkInformation": "4.1.0-beta-23516",
9+
"System.Net.WebSockets.Client": "4.0.0-beta-23516",
10+
"System.Data.SqlClient": "4.0.0-beta-23516",
11+
"System.Reflection.DispatchProxy": "4.0.1-beta-23516"
612
},
713
"commands": {
814
"PublishRuntimeDependency": "PublishRuntimeDependency"

src/Microsoft.Dnx.Tooling/Publish/PublishManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ public bool Publish()
294294
}
295295
else if (library.Type == LibraryTypes.Package)
296296
{
297-
if (!root.Packages.Any(p => p.Library.Name == library.Identity.Name))
297+
if (!root.Packages.Any(p => p.Library.Name == library.Identity.Name && p.Library.Version == library.Identity.Version))
298298
{
299299
root.Packages.Add(new PublishPackage((PackageDescription)library));
300300
}

0 commit comments

Comments
 (0)