Skip to content

Commit

Permalink
Migrate to csproj (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmds authored Dec 1, 2017
1 parent eba3d5d commit 54cff66
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 213 deletions.
96 changes: 52 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,69 +1,77 @@
[![AppVeyor](https://ci.appveyor.com/api/projects/status/g2arq8vpwasvvu4t?svg=true)](https://ci.appveyor.com/project/tmds/tmds-mdns/branch/master)
[![NuGet](https://img.shields.io/nuget/v/Tmds.MDns.svg)](https://www.nuget.org/packages/Tmds.MDns)

Tmds.MDns
=========

This library allows to find services announced via multicast DNS (RFC6762 and RFC6763).

AppVeyor: [![AppVeyor](https://ci.appveyor.com/api/projects/status/g2arq8vpwasvvu4t?svg=true)](https://ci.appveyor.com/project/tmds/tmds-mdns/branch/master)
Version 0.7.0+ is compatible with .NET Core and .NET Framework 4.0+.
Version 0.6 and below also supported .NET Framework 2.0, 3.5.
Support for these versions was dropped due to a dotnet cli msbuild issue:
https://github.com/Microsoft/msbuild/issues/1333.

Example
-------

This examples shows how to use the ServiceBrowser class to find \_workstation.\_tcp_ types.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Tmds.MDns;
```C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Tmds.MDns;

namespace ServiceFinder
namespace ServiceFinder
{
class Program
{
class Program
static void Main(string[] args)
{
static void Main(string[] args)
string serviceType = "_workstation._tcp";
if (args.Length >= 1)
{
string serviceType = "_workstation._tcp";
if (args.Length >= 1)
{
serviceType = args[0];
}

ServiceBrowser serviceBrowser = new ServiceBrowser();
serviceBrowser.ServiceAdded += onServiceAdded;
serviceBrowser.ServiceRemoved += onServiceRemoved;
serviceBrowser.ServiceChanged += onServiceChanged;

Console.WriteLine("Browsing for type: {0}", serviceType);
serviceBrowser.StartBrowse(serviceType);
Console.ReadLine();
serviceType = args[0];
}

static void onServiceChanged(object sender, ServiceAnnouncementEventArgs e)
{
printService('~', e.Announcement);
}
ServiceBrowser serviceBrowser = new ServiceBrowser();
serviceBrowser.ServiceAdded += onServiceAdded;
serviceBrowser.ServiceRemoved += onServiceRemoved;
serviceBrowser.ServiceChanged += onServiceChanged;

static void onServiceRemoved(object sender, ServiceAnnouncementEventArgs e)
{
printService('-', e.Announcement);
}
Console.WriteLine("Browsing for type: {0}", serviceType);
serviceBrowser.StartBrowse(serviceType);
Console.ReadLine();
}

static void onServiceAdded(object sender, ServiceAnnouncementEventArgs e)
{
printService('+', e.Announcement);
}
static void onServiceChanged(object sender, ServiceAnnouncementEventArgs e)
{
printService('~', e.Announcement);
}

static void printService(char startChar, ServiceAnnouncement service)
{
Console.WriteLine("{0} '{1}' on {2}", startChar, service.Instance, service.NetworkInterface.Name);
Console.WriteLine("\tHost: {0} ({1})", service.Hostname, string.Join(", ", service.Addresses));
Console.WriteLine("\tPort: {0}", service.Port);
Console.WriteLine("\tTxt : [{0}]", string.Join(", ", service.Txt));
}
static void onServiceRemoved(object sender, ServiceAnnouncementEventArgs e)
{
printService('-', e.Announcement);
}

static void onServiceAdded(object sender, ServiceAnnouncementEventArgs e)
{
printService('+', e.Announcement);
}

static void printService(char startChar, ServiceAnnouncement service)
{
Console.WriteLine("{0} '{1}' on {2}", startChar, service.Instance, service.NetworkInterface.Name);
Console.WriteLine("\tHost: {0} ({1})", service.Hostname, string.Join(", ", service.Addresses));
Console.WriteLine("\tPort: {0}", service.Port);
Console.WriteLine("\tTxt : [{0}]", string.Join(", ", service.Txt));
}
}
}
```

Implementation
--------------
Expand Down
22 changes: 0 additions & 22 deletions Tmds.MDns.sln

This file was deleted.

2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
init:
- git config --global core.autocrlf true
build_script:
- build.cmd --quiet verify
- build.cmd
clone_depth: 1
test: off
deploy: off
Expand Down
4 changes: 2 additions & 2 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@ECHO OFF
PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE"
dotnet restore src/Tmds.MDns
dotnet pack -c Release src/Tmds.MDns
67 changes: 0 additions & 67 deletions build.ps1

This file was deleted.

3 changes: 0 additions & 3 deletions global.json

This file was deleted.

12 changes: 12 additions & 0 deletions samples/ServiceFinder/ServiceFinder.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<ProjectReference Include="..\..\src\Tmds.MDns\Tmds.MDns.csproj" />
</ItemGroup>

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>

</Project>
16 changes: 0 additions & 16 deletions samples/ServiceFinder/project.json

This file was deleted.

30 changes: 30 additions & 0 deletions src/Tmds.MDns/Tmds.MDns.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>This library allows to find services announced via multicast DNS (RFC6762 and RFC6763).</Description>
<AssemblyTitle>Tmds.MDns</AssemblyTitle>
<VersionPrefix>0.7.0</VersionPrefix>
<Authors>Tom Deseyn</Authors>
<TargetFrameworks>netstandard1.3;net45;net40</TargetFrameworks>
<AssemblyName>Tmds.MDns</AssemblyName>
<PackageId>Tmds.MDns</PackageId>
<PackageTags>mdns;avahi;zeroconf;rfc6762;rfc6763</PackageTags>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>git://github.com/tmds/Tmds.MDns</RepositoryUrl>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<PackageReference Include="System.Net.NetworkInformation" Version="4.1.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

</Project>
21 changes: 0 additions & 21 deletions src/Tmds.MDns/Tmds.MDns.xproj

This file was deleted.

37 changes: 0 additions & 37 deletions src/Tmds.MDns/project.json

This file was deleted.

0 comments on commit 54cff66

Please sign in to comment.