update dotnet tutorial to use dotnet core instead of mono

This commit is contained in:
kjnilsson 2016-08-19 11:59:44 +01:00
parent 77167bf9d2
commit 6dac939cad
28 changed files with 292 additions and 121 deletions

6
.gitignore vendored
View File

@ -18,4 +18,8 @@ ruby*/rubygems*
java*/.idea/workspace.xml
java*/.idea/encodings.xml
*~
*~
.vscode/
obj/
bin/

20
dotnet/EmitLog/project.json Executable file
View File

@ -0,0 +1,20 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"RabbitMQ.Client": "4.0.*"
},
"imports": "dnxcore50"
}
}
}

View File

@ -0,0 +1,20 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"RabbitMQ.Client": "4.0.*"
},
"imports": "dnxcore50"
}
}
}

View File

@ -0,0 +1,20 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"RabbitMQ.Client": "4.0.*"
},
"imports": "dnxcore50"
}
}
}

20
dotnet/NewTask/project.json Executable file
View File

@ -0,0 +1,20 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"RabbitMQ.Client": "4.0.*"
},
"imports": "dnxcore50"
}
}
}

View File

@ -9,140 +9,47 @@ To successfully use the examples you will need a running RabbitMQ server.
### Requirements on Windows
You need the RabbitMQ dotnet client.
* Download [RabbitMQ .NET client](https://github.com/rabbitmq/rabbitmq-server/releases/download/rabbitmq_v3_5_4/rabbitmq-dotnet-client-3.5.4-dotnet-4.0.zip)
* Extract it and copy "RabbitMQ.Client.dll" to your working folder.
You also need to ensure your system can find the C# compiler `csc.exe`,
you may need to add `;C:\Windows\Microsoft.NET\Framework\v4.0.30319` (change .NET version
to fit your installation) to your `PATH`.
* [dotnet core](https://www.microsoft.com/net/core)
We're using the command line (start->run cmd.exe) to
compile and run the code. Alternatively you could [use Visual Studio](https://github.com/rabbitmq/rabbitmq-tutorials/tree/master/dotnet-visual-studio) and [NuGet package](https://www.nuget.org/packages/RabbitMQ.Client/), but
this set of tutorials assumes the command line.
compile and run -p the code. Alternatively you could [use Visual Studio](https://github.com/rabbitmq/rabbitmq-tutorials/tree/master/dotnet-visual-studio) and [NuGet package](https://www.nuget.org/packages/RabbitMQ.Client/), but this set of tutorials assumes
the command line.
### Requirements on Linux
You need Mono and RabbitMQ dotnet client.
sudo apt-get install mono-devel
mkdir lib
cd lib
wget https://github.com/rabbitmq/rabbitmq-server/releases/download/rabbitmq_v3_5_4/rabbitmq-dotnet-client-3.5.4-dotnet-4.0.zip
unzip rabbitmq-dotnet-client-3.5.4-dotnet-4.0.zip
cd ..
* [dotnet core](https://www.microsoft.com/net/core)
## Code
Each command is best run -p in a separate console/terminal instance run from the root
of the tutorial directory.
#### [Tutorial one: "Hello World!"](http://www.rabbitmq.com/tutorial-one-dotnet.html)
##### Windows
csc /r:"RabbitMQ.Client.dll" Send.cs
csc /r:"RabbitMQ.Client.dll" Receive.cs
Send.exe
Receive.exe
##### Linux
gmcs -r:lib/bin/RabbitMQ.Client.dll Send.cs
gmcs -r:lib/bin/RabbitMQ.Client.dll Receive.cs
MONO_PATH=lib/bin mono Send.exe
MONO_PATH=lib/bin mono Receive.exe
dotnet run -p Receive
dotnet run -p Send
#### [Tutorial two: Work Queues](http://www.rabbitmq.com/tutorial-two-dotnet.html)
##### Windows
csc /r:"RabbitMQ.Client.dll" NewTask.cs
csc /r:"RabbitMQ.Client.dll" Worker.cs
NewTask.exe
Worker.exe
##### Linux
gmcs -r:lib/bin/RabbitMQ.Client.dll NewTask.cs
gmcs -r:lib/bin/RabbitMQ.Client.dll Worker.cs
MONO_PATH=lib/bin mono NewTask.exe
MONO_PATH=lib/bin mono Worker.exe
dotnet run -p Worker
dotnet run -p NewTask
#### [Tutorial three: Publish/Subscribe](http://www.rabbitmq.com/tutorial-three-dotnet.html)
##### Windows
csc /r:"RabbitMQ.Client.dll" ReceiveLogs.cs
csc /r:"RabbitMQ.Client.dll" EmitLog.cs
ReceiveLogs.exe
EmitLog.exe
##### Linux
gmcs -r:lib/bin/RabbitMQ.Client.dll ReceiveLogs.cs
gmcs -r:lib/bin/RabbitMQ.Client.dll EmitLog.cs
MONO_PATH=lib/bin mono ReceiveLogs.exe
MONO_PATH=lib/bin mono EmitLog.exe
dotnet run -p ReceiveLogs
dotnet run -p EmitLog
#### [Tutorial four: Routing](http://www.rabbitmq.com/tutorial-four-dotnet.html)
##### Windows
csc /r:"RabbitMQ.Client.dll" ReceiveLogsDirect.cs
csc /r:"RabbitMQ.Client.dll" EmitLogDirect.cs
ReceiveLogsDirect.exe
EmitLogDirect.exe
##### Linux
gmcs -r:lib/bin/RabbitMQ.Client.dll ReceiveLogsDirect.cs
gmcs -r:lib/bin/RabbitMQ.Client.dll EmitLogDirect.cs
MONO_PATH=lib/bin mono ReceiveLogsDirect.exe
MONO_PATH=lib/bin mono EmitLogDirect.exe
dotnet run -p ReceiveLogsDirect info
dotnet run -p EmitLogDirect
#### [Tutorial five: Topics](http://www.rabbitmq.com/tutorial-five-dotnet.html)
##### Windows
csc /r:"RabbitMQ.Client.dll" ReceiveLogsTopic.cs
csc /r:"RabbitMQ.Client.dll" EmitLogTopic.cs
ReceiveLogsTopic.exe
EmitLogTopic.exe
##### Linux
gmcs -r:lib/bin/RabbitMQ.Client.dll ReceiveLogsTopic.cs
gmcs -r:lib/bin/RabbitMQ.Client.dll EmitLogTopic.cs
MONO_PATH=lib/bin mono ReceiveLogsTopic.exe
MONO_PATH=lib/bin mono EmitLogTopic.exe
dotnet run -p ReceiveLogsTopic anonymous.info
dotnet run -p EmitLogTopic
#### [Tutorial six: RPC](http://www.rabbitmq.com/tutorial-six-dotnet.html)
##### Windows
csc /r:"RabbitMQ.Client.dll" RPCServer.cs
csc /r:"RabbitMQ.Client.dll" RPCClient.cs
RPCServer.exe
RPCClient.exe
##### Linux
gmcs -r:lib/bin/RabbitMQ.Client.dll RPCServer.cs
gmcs -r:lib/bin/RabbitMQ.Client.dll RPCClient.cs
MONO_PATH=lib/bin mono RPCServer.exe
MONO_PATH=lib/bin mono RPCClient.exe
dotnet run -p RPCServer
dotnet run -p RPCClient

20
dotnet/RPCClient/project.json Executable file
View File

@ -0,0 +1,20 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"RabbitMQ.Client": "4.0.*"
},
"imports": "dnxcore50"
}
}
}

20
dotnet/RPCServer/project.json Executable file
View File

@ -0,0 +1,20 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"RabbitMQ.Client": "4.0.*"
},
"imports": "dnxcore50"
}
}
}

20
dotnet/Receive/project.json Executable file
View File

@ -0,0 +1,20 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"RabbitMQ.Client": "4.0.*"
},
"imports": "dnxcore50"
}
}
}

20
dotnet/ReceiveLogs/project.json Executable file
View File

@ -0,0 +1,20 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"RabbitMQ.Client": "4.0.*"
},
"imports": "dnxcore50"
}
}
}

View File

@ -5,7 +5,7 @@
class ReceiveLogsDirect
{
public static void Main(string[] args)
public static int Main(string[] args)
{
var factory = new ConnectionFactory() { HostName = "localhost" };
using(var connection = factory.CreateConnection())
@ -19,8 +19,7 @@ public static void Main(string[] args)
Console.Error.WriteLine("Usage: {0} [info] [warning] [error]", Environment.GetCommandLineArgs()[0]);
Console.WriteLine(" Press [enter] to exit.");
Console.ReadLine();
Environment.ExitCode = 1;
return;
return 1;
}
foreach(var severity in args)
@ -42,6 +41,7 @@ public static void Main(string[] args)
Console.WriteLine(" Press [enter] to exit.");
Console.ReadLine();
return 0;
}
}
}

View File

@ -0,0 +1,20 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"RabbitMQ.Client": "4.0.*"
},
"imports": "dnxcore50"
}
}
}

View File

@ -5,7 +5,7 @@
class ReceiveLogsTopic
{
public static void Main(string[] args)
public static int Main(string[] args)
{
var factory = new ConnectionFactory() { HostName = "localhost" };
using(var connection = factory.CreateConnection())
@ -19,8 +19,7 @@ public static void Main(string[] args)
Console.Error.WriteLine("Usage: {0} [binding_key...]", Environment.GetCommandLineArgs()[0]);
Console.WriteLine(" Press [enter] to exit.");
Console.ReadLine();
Environment.ExitCode = 1;
return;
return 1;
}
foreach(var bindingKey in args)
@ -42,6 +41,7 @@ public static void Main(string[] args)
Console.WriteLine(" Press [enter] to exit.");
Console.ReadLine();
return 0;
}
}
}

View File

@ -0,0 +1,20 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"RabbitMQ.Client": "4.0.*"
},
"imports": "dnxcore50"
}
}
}

20
dotnet/Receiver Executable file
View File

@ -0,0 +1,20 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"RabbitMQ.Client": "4.0.*"
},
"imports": "dnxcore50"
}
}
}

20
dotnet/Send/project.json Executable file
View File

@ -0,0 +1,20 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"RabbitMQ.Client": "4.0.*"
},
"imports": "dnxcore50"
}
}
}

20
dotnet/Worker/project.json Executable file
View File

@ -0,0 +1,20 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"RabbitMQ.Client": "4.0.*"
},
"imports": "dnxcore50"
}
}
}

View File

@ -1,5 +1,5 @@
#!/bin/sh
for f in *.cs; do \
mcs -r:lib/bin/RabbitMQ.Client.dll $f; \
for f in */; do \
dotnet build $f
done