THRIFT-4350: enable dotnet-2.0.0-sdk in ubuntu xenial, update netcore
projects, get them running with make cross
Client: netcore

This closes #1379
diff --git a/test/known_failures_Linux.json b/test/known_failures_Linux.json
index 0a5953a..d424772 100644
--- a/test/known_failures_Linux.json
+++ b/test/known_failures_Linux.json
@@ -169,4 +169,4 @@
   "java-d_compact_framed-ip",
   "rs-dart_binary_framed-ip",
   "rs-dart_compact_framed-ip"
-]
\ No newline at end of file
+]
diff --git a/test/netcore/Makefile.am b/test/netcore/Makefile.am
index 21a6e7d..e84a57a 100644
--- a/test/netcore/Makefile.am
+++ b/test/netcore/Makefile.am
@@ -23,13 +23,6 @@
 
 GENDIR = ThriftTest/gen-netcore
 
-# Due to a known issue with "dotnet restore" the Thrift.dll dependency cannot be resolved from cmdline.
-# The problem does NOT affect Visual Studio builds, only cmdline. 
-# - For details see https://github.com/dotnet/cli/issues/3199 and related tickets.
-# - Workaround is to temporarily copy the Thrift project into the solution
-COPYCMD = cp  -u -p -r
-	
-
 THRIFTCODE = \
 			ThriftTest/TestClient.cs \
 			ThriftTest/TestServer.cs \
@@ -37,32 +30,29 @@
 			ThriftTest/Program.cs 
 
 all-local: \
-	ThriftTest.exe
+	ThriftTest/stage/ThriftTest.dll
 
-ThriftTest.exe: $(THRIFTCODE)
+ThriftTest/stage/ThriftTest.dll: $(THRIFTCODE)
 	$(MKDIR_P) $(GENDIR)
 	$(THRIFT)  -gen netcore:wcf   -r  -out $(GENDIR)  $(top_srcdir)/test/ThriftTest.thrift
-	$(MKDIR_P) ./Thrift
-	$(COPYCMD)  $(top_srcdir)/lib/netcore/Thrift/*  ./Thrift
 	$(DOTNETCORE) --info
 	$(DOTNETCORE) restore
-	$(DOTNETCORE) build **/*/project.json -r win10-x64 
-	$(DOTNETCORE) build **/*/project.json -r osx.10.11-x64 
-	$(DOTNETCORE) build **/*/project.json -r ubuntu.16.04-x64 
+	$(DOTNETCORE) build
+
+precross: \
+	ThriftTest/stage/ThriftTest.dll
 
 clean-local:
 	$(RM) ThriftTest.exe
 	$(RM) -r $(GENDIR)
 	$(RM) -r ThriftTest/bin
 	$(RM) -r ThriftTest/obj
-	$(RM) -r Thrift
 
 EXTRA_DIST = \
 			 $(THRIFTCODE) \
-			 global.json \
-			 ThriftTest/project.json \
-			 ThriftTest/ThriftTest.sln \
-			 ThriftTest/ThriftTest.xproj \
+			 ThriftTest.sln \
+			 ThriftTest/ThriftTest.csproj \
 			 build.cmd \
-			 build.sh
+			 build.sh \
+			 README.md
 			 
diff --git a/test/netcore/README.md b/test/netcore/README.md
index 230897f..05eb0e2 100644
--- a/test/netcore/README.md
+++ b/test/netcore/README.md
@@ -6,12 +6,12 @@
 - ThriftTest - tests for Thrift library 
 
 # Reused components 
-- NET Core Standard 1.6 (SDK 1.0.0-preview2-003121)
-- NET Core App 1.1
+- NET Core Standard 1.6 (SDK 2.0.0)
 
-# How to build
-- Download and install .NET Core SDK for your platform https://www.microsoft.com/net/core#windowsvs2015 (archive for SDK 1.0.0-preview2-003121 located by: https://github.com/dotnet/core/blob/master/release-notes/download-archive.md)
-- Ensure that you have thrift.exe which supports netcore lib and it added to PATH 
-- Go to current folder 
-- Run **build.sh** or **build.cmd** from the root of cloned repository
+# How to build on Windows
+- Open ThriftTest.sln in Visual Studio and build
+
+# How to build on Unix
+- Ensure you have .NET Core 2.0.0 SDK installed or use the Ubuntu Xenial docker image
+- Follow common build practice for Thrift: bootstrap, configure, and make precross
 
diff --git a/test/netcore/ThriftTest.sln b/test/netcore/ThriftTest.sln
new file mode 100644
index 0000000..c3f194b
--- /dev/null
+++ b/test/netcore/ThriftTest.sln
@@ -0,0 +1,50 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.26730.12
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ThriftTest", "ThriftTest\ThriftTest.csproj", "{DDED46FF-F359-47B4-BA7E-9B70F216BD44}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Thrift", "..\..\lib\netcore\Thrift\Thrift.csproj", "{C20EA2A9-7660-47DE-9A49-D1EF12FB2895}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Debug|x64 = Debug|x64
+		Debug|x86 = Debug|x86
+		Release|Any CPU = Release|Any CPU
+		Release|x64 = Release|x64
+		Release|x86 = Release|x86
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{DDED46FF-F359-47B4-BA7E-9B70F216BD44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{DDED46FF-F359-47B4-BA7E-9B70F216BD44}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{DDED46FF-F359-47B4-BA7E-9B70F216BD44}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{DDED46FF-F359-47B4-BA7E-9B70F216BD44}.Debug|x64.Build.0 = Debug|Any CPU
+		{DDED46FF-F359-47B4-BA7E-9B70F216BD44}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{DDED46FF-F359-47B4-BA7E-9B70F216BD44}.Debug|x86.Build.0 = Debug|Any CPU
+		{DDED46FF-F359-47B4-BA7E-9B70F216BD44}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{DDED46FF-F359-47B4-BA7E-9B70F216BD44}.Release|Any CPU.Build.0 = Release|Any CPU
+		{DDED46FF-F359-47B4-BA7E-9B70F216BD44}.Release|x64.ActiveCfg = Release|Any CPU
+		{DDED46FF-F359-47B4-BA7E-9B70F216BD44}.Release|x64.Build.0 = Release|Any CPU
+		{DDED46FF-F359-47B4-BA7E-9B70F216BD44}.Release|x86.ActiveCfg = Release|Any CPU
+		{DDED46FF-F359-47B4-BA7E-9B70F216BD44}.Release|x86.Build.0 = Release|Any CPU
+		{C20EA2A9-7660-47DE-9A49-D1EF12FB2895}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{C20EA2A9-7660-47DE-9A49-D1EF12FB2895}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{C20EA2A9-7660-47DE-9A49-D1EF12FB2895}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{C20EA2A9-7660-47DE-9A49-D1EF12FB2895}.Debug|x64.Build.0 = Debug|Any CPU
+		{C20EA2A9-7660-47DE-9A49-D1EF12FB2895}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{C20EA2A9-7660-47DE-9A49-D1EF12FB2895}.Debug|x86.Build.0 = Debug|Any CPU
+		{C20EA2A9-7660-47DE-9A49-D1EF12FB2895}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{C20EA2A9-7660-47DE-9A49-D1EF12FB2895}.Release|Any CPU.Build.0 = Release|Any CPU
+		{C20EA2A9-7660-47DE-9A49-D1EF12FB2895}.Release|x64.ActiveCfg = Release|Any CPU
+		{C20EA2A9-7660-47DE-9A49-D1EF12FB2895}.Release|x64.Build.0 = Release|Any CPU
+		{C20EA2A9-7660-47DE-9A49-D1EF12FB2895}.Release|x86.ActiveCfg = Release|Any CPU
+		{C20EA2A9-7660-47DE-9A49-D1EF12FB2895}.Release|x86.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {52CE9A12-F6CB-4F0C-BB42-0105612F5FF4}
+	EndGlobalSection
+EndGlobal
diff --git a/test/netcore/ThriftTest/TestClient.cs b/test/netcore/ThriftTest/TestClient.cs
index d9f9563..f6cc900 100644
--- a/test/netcore/ThriftTest/TestClient.cs
+++ b/test/netcore/ThriftTest/TestClient.cs
@@ -89,6 +89,11 @@
                     {
                         numThreads = Convert.ToInt32(args[++i]);
                     }
+                    else if (args[i] == "--binary" || args[i] == "--protocol=binary")
+                    {
+                        protocol = "binary";
+                        Console.WriteLine("Using binary protocol");
+                    }
                     else if (args[i] == "--compact" || args[i] == "--protocol=compact")
                     {
                         protocol = "compact";
@@ -890,4 +895,4 @@
             return returnCode;
         }
     }
-}
\ No newline at end of file
+}
diff --git a/test/netcore/ThriftTest/TestServer.cs b/test/netcore/ThriftTest/TestServer.cs
index 7976c5d..aa25c91 100644
--- a/test/netcore/ThriftTest/TestServer.cs
+++ b/test/netcore/ThriftTest/TestServer.cs
@@ -63,6 +63,10 @@
                 {
                     useFramed = true;
                 }
+                else if (args[i] == "--binary" || args[i] == "--protocol=binary")
+                {
+                    // nothing needed
+                }
                 else if (args[i] == "--compact" || args[i] == "--protocol=compact")
                 {
                     compact = true;
@@ -493,8 +497,8 @@
                 {
                     if (param.useEncryption)
                     {
-                        var certPath = "../keys/server.p12";
-                        trans = new TTlsServerSocketTransport(param.port, param.useBufferedSockets, new X509Certificate2(certPath, "thrift"), null, null, SslProtocols.Tls12);
+                        var certPath = "../../keys/server.p12";
+                        trans = new TTlsServerSocketTransport(param.port, param.useBufferedSockets, new X509Certificate2(certPath, "thrift"), null, null, SslProtocols.Tls);
                     }
                     else
                     {
diff --git a/test/netcore/ThriftTest/ThriftTest.csproj b/test/netcore/ThriftTest/ThriftTest.csproj
new file mode 100644
index 0000000..6647101
--- /dev/null
+++ b/test/netcore/ThriftTest/ThriftTest.csproj
@@ -0,0 +1,27 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netcoreapp2.0</TargetFramework>
+    <AssemblyName>ThriftTest</AssemblyName>
+    <PackageId>ThriftTest</PackageId>
+    <OutputType>Exe</OutputType>
+    <GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
+    <GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
+    <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
+    <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
+    <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
+    <GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="System.Net.Http.WinHttpHandler" Version="[4.4,)" />
+    <PackageReference Include="System.Runtime.Serialization.Primitives" Version="[4.3,)" />
+    <PackageReference Include="System.ServiceModel.Primitives" Version="[4.4,)" />
+    <PackageReference Include="System.Threading" Version="[4.3,)" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\..\..\lib\netcore\Thrift\Thrift.csproj" />
+  </ItemGroup>
+
+</Project>
diff --git a/test/netcore/ThriftTest/ThriftTest.sln b/test/netcore/ThriftTest/ThriftTest.sln
deleted file mode 100644
index 03b4f3d..0000000
--- a/test/netcore/ThriftTest/ThriftTest.sln
+++ /dev/null
@@ -1,33 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
-VisualStudioVersion = 14.0.25420.1
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ThriftTest", "ThriftTest.xproj", "{B0C13DA0-3117-4844-8AE8-B1775E46223D}"
-EndProject
-Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Thrift", "..\..\..\lib\netcore\Thrift\Thrift.xproj", "{6850CF46-5467-4C65-BD78-871581C539FC}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{839DBA0F-2D58-4266-A30D-3392BD710A59}"
-	ProjectSection(SolutionItems) = preProject
-		..\global.json = ..\global.json
-	EndProjectSection
-EndProject
-Global
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Any CPU = Debug|Any CPU
-		Release|Any CPU = Release|Any CPU
-	EndGlobalSection
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{B0C13DA0-3117-4844-8AE8-B1775E46223D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{B0C13DA0-3117-4844-8AE8-B1775E46223D}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{B0C13DA0-3117-4844-8AE8-B1775E46223D}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{B0C13DA0-3117-4844-8AE8-B1775E46223D}.Release|Any CPU.Build.0 = Release|Any CPU
-		{6850CF46-5467-4C65-BD78-871581C539FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{6850CF46-5467-4C65-BD78-871581C539FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{6850CF46-5467-4C65-BD78-871581C539FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{6850CF46-5467-4C65-BD78-871581C539FC}.Release|Any CPU.Build.0 = Release|Any CPU
-	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
-EndGlobal
diff --git a/test/netcore/ThriftTest/ThriftTest.xproj b/test/netcore/ThriftTest/ThriftTest.xproj
deleted file mode 100644
index 7746cc8..0000000
--- a/test/netcore/ThriftTest/ThriftTest.xproj
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <PropertyGroup>
-    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
-    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
-  </PropertyGroup>
-
-  <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''"  />
-  <PropertyGroup Label="Globals">
-    <ProjectGuid>B0C13DA0-3117-4844-8AE8-B1775E46223D</ProjectGuid>
-    <RootNamespace>ThriftTest</RootNamespace>
-    <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
-    <OutputPath Condition="'$(OutputPath)'=='' ">bin\$(MSBuildProjectName)\</OutputPath>
-    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
-  </PropertyGroup>
-
-  <PropertyGroup>
-    <SchemaVersion>2.0</SchemaVersion>
-  </PropertyGroup>
-  <Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
-</Project>
diff --git a/test/netcore/ThriftTest/project.json b/test/netcore/ThriftTest/project.json
deleted file mode 100644
index 56d2777..0000000
--- a/test/netcore/ThriftTest/project.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
-  "version": "1.0.0-*",
-  "buildOptions": {
-    "emitEntryPoint": true
-  },
-
-  "runtimes": {
-    "win10-x64": {},
-    "osx.10.11-x64": {},
-    "ubuntu.16.04-x64": {}
-  },
-
-  "dependencies": {
-    "System.Runtime.Serialization.Primitives": "4.1.1",
-    "System.ServiceModel.Primitives": "4.0.0"
-  },
-
-  "frameworks": {
-    "netcoreapp1.0": {
-      "imports": "dnxcore50",
-      "dependencies": {
-        "Thrift": "1.0.0-*",
-        "Microsoft.NETCore.App": {
-          "version": "1.0.0"
-        }
-      }
-    }
-  }
-}
diff --git a/test/netcore/build.cmd b/test/netcore/build.cmd
index 88ff20a..e971799 100644
--- a/test/netcore/build.cmd
+++ b/test/netcore/build.cmd
@@ -19,27 +19,12 @@
 rem  */
 setlocal
 
-cd ThriftTest
-thrift  -gen netcore:wcf   -r  ..\..\ThriftTest.thrift
+cd Interfaces
+thrift  -gen netcore:wcf   -r  ..\..\tutorial.thrift
 cd ..
 
-rem * Due to a known issue with "dotnet restore" the Thrift.dll dependency cannot be resolved from cmdline
-rem * For details see https://github.com/dotnet/cli/issues/3199 and related tickets
-rem * The problem does NOT affect Visual Studio builds.
-
-rem * workaround for "dotnet restore" issue
-xcopy ..\..\lib\netcore\Thrift .\Thrift  /YSEI  >NUL
-
 dotnet --info
 dotnet restore
-
-dotnet build **/*/project.json -r win10-x64 
-dotnet build **/*/project.json -r osx.10.11-x64 
-dotnet build **/*/project.json -r ubuntu.16.04-x64 
-
-rem * workaround for "dotnet restore" issue
-del .\Thrift\*  /Q /S  >NUL
-rd  .\Thrift    /Q /S  >NUL
-
+dotnet build
 
 :eof
diff --git a/test/netcore/build.sh b/test/netcore/build.sh
old mode 100644
new mode 100755
index 3acd78a..626635c
--- a/test/netcore/build.sh
+++ b/test/netcore/build.sh
@@ -20,35 +20,12 @@
 #
 
 #exit if any command fails
-#set -e
+set -e
 
 cd ThriftTest
 ../../../compiler/cpp/thrift  -gen netcore:wcf   -r  ../../ThriftTest.thrift
 cd ..
 
-
-# Due to a known issue with "dotnet restore" the Thrift.dll dependency cannot be resolved from cmdline
-# For details see https://github.com/dotnet/cli/issues/3199 and related tickets
-# The problem does NOT affect Visual Studio builds.
-
-# workaround for "dotnet restore" issue
-cp  -u -p -r ..\..\lib\netcore\Thrift .\Thrift  
-
 dotnet --info
 dotnet restore
-
-# dotnet test ./test/TEST_PROJECT_NAME -c Release -f netcoreapp1.0
-
-# Instead, run directly with mono for the full .net version 
-dotnet build **/*/project.json -r win10-x64 
-dotnet build **/*/project.json -r osx.10.11-x64 
-dotnet build **/*/project.json -r ubuntu.16.04-x64 
-
-#revision=${TRAVIS_JOB_ID:=1}  
-#revision=$(printf "%04d" $revision) 
-
-#dotnet pack ./src/PROJECT_NAME -c Release -o ./artifacts --version-suffix=$revision  
-
-# workaround for "dotnet restore" issue
-rm -r .\Thrift  
-
+dotnet build
diff --git a/test/netcore/global.json b/test/netcore/global.json
deleted file mode 100644
index 42ed97a..0000000
--- a/test/netcore/global.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
-  "projects": [ "../../lib/netcore" ],
-   "sdk": {
-    "version": "1.0.0-preview2-1-003177" // "1.0.0-preview2-003121", "1.0.0-preview4-004233"
-  }
-}
\ No newline at end of file
diff --git a/test/tests.json b/test/tests.json
index a926486..fdd725c 100644
--- a/test/tests.json
+++ b/test/tests.json
@@ -397,15 +397,25 @@
       "compact",
       "json"
     ],
-    "server": {
+    "server-disabled": {
       "command": [
-        "dotnet restore && dotnet run server"
+        "dotnet",
+        "run",
+	"--no-build",
+	"--no-restore",
+	"--",
+        "server"
       ]
     },
     "client": {
       "timeout": 10,
       "command": [
-        "dotnet run client"
+        "dotnet",
+        "run",
+	"--no-build",
+	"--no-restore",
+	"--",
+        "client"
       ]
     },
     "workdir": "netcore/ThriftTest"