Skip to content

Commit 8bbf914

Browse files
connieyluigiberrettini
authored andcommitted
Migrates project to .NET Core (#38)
* Removing LeaveDotsAndSlashesEscaped because it does not apply * Fixing async/await methods * Consolidating dependencies for EasyNetQ.Management.Client * Using HttpClient instead of WebRequest * Using project.json instead of packages.config * Changing tests to use xproj so they compile easily * Fixing Appveyor build * Embedding referenced Version into xproj * Removing unused csproj
1 parent 9e1991c commit 8bbf914

15 files changed

Lines changed: 207 additions & 247 deletions

Build/EasyNetQ.proj

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
<BuildNumber Condition=" '$(BUILD_NUMBER)' != '' ">$(BUILD_NUMBER)</BuildNumber>
1515
<BuildNumber Condition=" '$(BuildNumber)' == '' ">0</BuildNumber>
1616
</PropertyGroup>
17+
18+
<!-- Properties that are set during build to find test/merge binaries -->
19+
<PropertyGroup>
20+
<Configuration>Release</Configuration>
21+
<DesktopFrameworkVersion>net451</DesktopFrameworkVersion>
22+
<BinaryDesktopFolder>bin\$(Configuration)\$(DesktopFrameworkVersion)</BinaryDesktopFolder>
23+
</PropertyGroup>
1724

1825
<Import Project="$(MSBuildCommunityTasksPath)\MSBuild.Community.Tasks.Targets"/>
1926

@@ -27,7 +34,7 @@
2734

2835
<ItemGroup>
2936
<ProjectToBuild Include="$(Source)\EasyNetQ.sln">
30-
<Properties>OutputPath=$(OutputDir);Configuration=Release</Properties>
37+
<Properties>OutputPath=$(OutputDir);Configuration=$(Configuration)</Properties>
3138
</ProjectToBuild>
3239
</ItemGroup>
3340

@@ -36,16 +43,20 @@
3643
</Target>
3744

3845
<Target Name="Test" DependsOnTargets="Build">
39-
<CreateItem Include="$(OutputDir)\*.Tests.dll">
40-
<Output TaskParameter="Include" ItemName="TestAssembly" />
41-
</CreateItem>
46+
<ItemGroup>
47+
<TestAssembly Include="$(OutputDir)\**\net451\*.Tests.dll" />
48+
</ItemGroup>
4249
<NUnit ToolPath="$(Nunit)" DisableShadowCopy="true" Assemblies="@(TestAssembly)" Framework="4.0.30319" Force32Bit="true" />
4350
</Target>
4451

4552
<Target Name="MergeManagementClient" DependsOnTargets="Test">
53+
<ItemGroup>
54+
<MergeAssemblies Include="$(OutputDir)\EasyNetQ.Management.Client\$(BinaryDesktopFolder)\EasyNetQ.Management.Client.dll" />
55+
<MergeAssemblies Include="$(OutputDir)\EasyNetQ.Management.Client\$(BinaryDesktopFolder)\Newtonsoft.Json.dll" />
56+
</ItemGroup>
4657
<Exec
4758
WorkingDirectory="$(OutputDir)"
48-
Command="$(ILRepack) /internalize /targetplatform:v4 /out:$(OutputDir)\EasyNetQ.Management.Client.dll $(OutputDir)\EasyNetQ.Management.Client.dll $(OutputDir)\Newtonsoft.Json.dll" />
59+
Command="$(ILRepack) /internalize /targetplatform:v4 /out:$(OutputDir)\EasyNetQ.Management.Client.dll @(MergeAssemblies->'%(Fullpath)', ' ')" />
4960
</Target>
5061

5162
<Target Name="PackageManagementClient" DependsOnTargets="MergeManagementClient">

Source/EasyNetQ.Management.Client.IntegrationTests/EasyNetQ.Management.Client.IntegrationTests.csproj

Lines changed: 0 additions & 76 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
5+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
6+
</PropertyGroup>
7+
8+
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
9+
<PropertyGroup Label="Globals">
10+
<ProjectGuid>{92F61BE0-9035-476E-BD2E-E8ACD67A03C5}</ProjectGuid>
11+
<RootNamespace>EasyNetQ.Management.Client</RootNamespace>
12+
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
13+
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
14+
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
15+
</PropertyGroup>
16+
17+
<PropertyGroup>
18+
<SchemaVersion>2.0</SchemaVersion>
19+
</PropertyGroup>
20+
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
21+
</Project>

Source/EasyNetQ.Management.Client.IntegrationTests/ManagementClientTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using EasyNetQ.Management.Client.Model;
44
using NUnit.Framework;
55
using System;
6-
using System.CodeDom;
76
using System.Collections.Generic;
87
using System.Linq;
98

Source/EasyNetQ.Management.Client.IntegrationTests/packages.config

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"dependencies": {
3+
"EasyNetQ.Management.Client": "2.0.0-netcore0001",
4+
"Newtonsoft.Json": "9.0.1",
5+
"NUnit": "2.6.4"
6+
},
7+
"buildOptions": {
8+
"compile": {
9+
"includeFiles": "..\\Version.cs"
10+
}
11+
},
12+
"frameworks": {
13+
"net451": {
14+
"frameworkAssemblies": {
15+
"Microsoft.CSharp": "4.0.0.0",
16+
"System.Net.Http": "4.0.0.0"
17+
}
18+
}
19+
},
20+
"runtimes": {
21+
"win": {}
22+
}
23+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
5+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
6+
</PropertyGroup>
7+
8+
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
9+
<PropertyGroup Label="Globals">
10+
<ProjectGuid>{F411090D-1CAB-4726-9F2B-582E9D9D80D7}</ProjectGuid>
11+
<RootNamespace>EasyNetQ.Management.Client</RootNamespace>
12+
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
13+
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
14+
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
15+
</PropertyGroup>
16+
17+
<PropertyGroup>
18+
<SchemaVersion>2.0</SchemaVersion>
19+
</PropertyGroup>
20+
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
21+
</Project>

Source/EasyNetQ.Management.Client.Tests/packages.config

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"dependencies": {
3+
"EasyNetQ.Management.Client": "2.0.0-netcore0001",
4+
"Newtonsoft.Json": "9.0.1",
5+
"NUnit": "2.6.4"
6+
},
7+
"buildOptions": {
8+
"embed": [ "Json/*" ],
9+
"compile": {
10+
"includeFiles": "..\\Version.cs"
11+
}
12+
},
13+
"frameworks": {
14+
"net451": {
15+
"frameworkAssemblies": {
16+
"Microsoft.CSharp": "4.0.0.0",
17+
"System.Net.Http": "4.0.0.0"
18+
}
19+
}
20+
},
21+
"runtimes": {
22+
"win": {}
23+
}
24+
}
Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
1-
using System.Net;
1+
using System.Net.Http;
2+
using System.Threading.Tasks;
23

34
namespace EasyNetQ.Management.Client
45
{
56
public static class HttpWebRequestExtensions
67
{
7-
public static HttpWebResponse GetHttpResponse(this HttpWebRequest request)
8+
public static HttpResponseMessage GetHttpResponse(this HttpRequestMessage request)
89
{
9-
HttpWebResponse response = null;
10+
return GetHttpResponseAsync(request).Result;
11+
}
1012

11-
try
12-
{
13-
response = (HttpWebResponse)request.GetResponseAsync().Result;
14-
}
15-
catch (WebException exception)
13+
/// <summary>
14+
/// https://blogs.msdn.microsoft.com/pfxteam/2012/04/13/should-i-expose-synchronous-wrappers-for-asynchronous-methods/
15+
/// </summary>
16+
public static async Task<HttpResponseMessage> GetHttpResponseAsync(this HttpRequestMessage request)
17+
{
18+
using (var client = new HttpClient())
1619
{
17-
if (exception.Status == WebExceptionStatus.ProtocolError)
18-
{
19-
response = (HttpWebResponse) exception.Response;
20-
}
21-
else
22-
{
23-
throw;
24-
}
20+
return await client.SendAsync(request).ConfigureAwait(false);
2521
}
26-
27-
return response;
2822
}
2923
}
3024
}

0 commit comments

Comments
 (0)