Skip to content

Commit 8ca1e0b

Browse files
authored
Fix/old connection random (#3391)
* FEATURE_HTTP_WEB_REQUEST is outdated both netstandard2x and net4x support it, rely on DOTNETCORE pragma only * update .editorconfig to make sure props and targets are formatted like xml and csproj * Move away from Directory.build.props for a more explicit inclusion approach, reformatted Solution items and moved scripts out of Solution items * Remove random old connection usage and add explict net461 testing back * Remove Tests\Directory.build.props it set a TESTINGNUGETPACKAGE pragma which was never used * cleanup namespaces on full .net HttpConnection alias class * Obsolete HttpWebRequestConnection on CoreFX since it does not reuse HttpClient instances * Revert "Remove Tests\Directory.build.props it set a TESTINGNUGETPACKAGE pragma which was never used" This reverts commit da2d826. * Remove setting of the TESTINGNUGETPACKAGE constant, not used anywher * Comment looping up for Directory.build.props for now * Add root Directory.build.props (for now only sets LangVersion to latest)
1 parent 7af56e0 commit 8ca1e0b

39 files changed

+150
-136
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ indent_size = 4
1616
indent_style = space
1717
indent_size = 4
1818

19-
[*.{md,markdown,json,js,csproj,fsproj,targets}]
19+
[*.{md,markdown,json,js,csproj,fsproj,targets,targets,props}]
2020
indent_style = space
2121
indent_size = 2
2222

build/scripts/scripts.fsproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@
6161
<None Include="Commandline.fsx" />
6262
<None Include="Targets.fsx" />
6363
</ItemGroup>
64+
<ItemGroup>
65+
<Content Include="..\..\paket.bat"><Link>paket.bat</Link></Content>
66+
<Content Include="..\..\paket.dependencies"><Link>paket.bat</Link></Content>
67+
<Content Include="..\..\build.sh"><Link>paket.bat</Link></Content>
68+
<Content Include="..\..\build.bat"><Link>paket.bat</Link></Content>
69+
</ItemGroup>
6470
<PropertyGroup>
6571
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
6672
</PropertyGroup>

src/Artifacts.build.props

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), build.bat))\src\Library.build.props" />
4+
<!--
5+
Sets up the properties for assemblies we want to publish to a separate output folder (outside of src) during our build process.
6+
e.g ApiGenerator we'd like to keep private but we do want to publish it to build/_output during our FAKE build
7+
-->
8+
<PropertyGroup>
9+
<OutputPath Condition="'$(OutputPathBaseDir)' != ''">$(OutputPathBaseDir)\$(MSBuildProjectName)\</OutputPath>
10+
</PropertyGroup>
11+
</Project>

src/CodeGeneration/ApiGenerator/ApiGenerator.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk">
3+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), build.bat))\src\Artifacts.build.props" />
34
<PropertyGroup>
45
<OutputType>Exe</OutputType>
56
<TargetFramework>netcoreapp2.1</TargetFramework>
@@ -17,5 +18,4 @@
1718
<PackageReference Include="RazorLight.Unofficial" Version="2.0.0-beta1.1" />
1819
<!--<PackageReference Include="RazorLight" Version="2.0.0-beta1" />-->
1920
</ItemGroup>
20-
<Import Project="..\..\outputpath.props" />
2121
</Project>

src/CodeGeneration/DocGenerator/Buildalyzer/ProjectAnalyzer.cs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ public Project Load()
119119
}
120120
}
121121

122+
123+
122124
// Tweaks the project file a bit to ensure a succesfull build
123125
private static XDocument TweakProjectDocument(XDocument projectDocument, string projectFolder)
124126
{
@@ -128,10 +130,12 @@ private static XDocument TweakProjectDocument(XDocument projectDocument, string
128130
if (att == null) continue;
129131

130132
var project = att.Value;
131-
if (project.EndsWith("Clients.Common.targets"))
132-
att.Value = Path.GetFullPath(Path.Combine(projectFolder, att.Value));
133-
else if (project.EndsWith("outputpath.props"))
134-
att.Value = Path.GetFullPath(Path.Combine(projectFolder, att.Value));
133+
134+
if (!ResolveKnownPropsPath(projectFolder, project, att, "PublishArtifacts.build.props"))
135+
{
136+
ResolveKnownPropsPath(projectFolder, project, att, "Artifacts.build.props");
137+
}
138+
ResolveKnownPropsPath(projectFolder, project, att, "Library.build.props");
135139
}
136140
// Add SkipGetTargetFrameworkProperties to every ProjectReference
137141
foreach (XElement projectReference in projectDocument.GetDescendants("ProjectReference").ToArray())
@@ -149,6 +153,17 @@ private static XDocument TweakProjectDocument(XDocument projectDocument, string
149153
return projectDocument;
150154
}
151155

156+
private static bool ResolveKnownPropsPath(string projectFolder, string project, XAttribute att, string buildPropFile)
157+
{
158+
if (!project.Contains(buildPropFile)) return false;
159+
var dir = new DirectoryInfo(projectFolder).Parent;
160+
while (dir != null && dir.Name != "src")
161+
dir = dir.Parent;
162+
if (dir == null) return true;
163+
att.Value = Path.GetFullPath(Path.Combine(dir.FullName, buildPropFile));
164+
return false;
165+
}
166+
152167
private ProjectCollection CreateProjectCollection()
153168
{
154169
ProjectCollection projectCollection = new ProjectCollection(_globalProperties);

src/CodeGeneration/DocGenerator/DocGenerator.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk">
3+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), build.bat))\src\Artifacts.build.props" />
34
<PropertyGroup>
45
<OutputType>Exe</OutputType>
56
<TargetFramework>netcoreapp2.1</TargetFramework>
@@ -17,5 +18,4 @@
1718
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="2.3.2" />
1819
<PackageReference Include="NuDoq" Version="1.2.5" />
1920
</ItemGroup>
20-
<Import Project="..\..\outputpath.props" />
2121
</Project>

src/Directory.build.props

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,5 @@
11
<Project>
22
<PropertyGroup>
3-
<!-- Default Version numbers -->
4-
<CurrentVersion>6.0.0</CurrentVersion>
5-
<CurrentAssemblyVersion>6.0.0</CurrentAssemblyVersion>
6-
<CurrentAssemblyFileVersion>6.0.0</CurrentAssemblyFileVersion>
7-
<!-- Version and Informational reflect actual version -->
8-
<Version>$(CurrentVersion)</Version>
9-
<InformationalVersion>$(CurrentVersion)</InformationalVersion>
10-
<!-- Assembly version is sticky to MAJOR.0.0.0 to avoid binding redirects because we strong name our assemblies -->
11-
<AssemblyVersion>$(CurrentAssemblyVersion)</AssemblyVersion>
12-
<!-- File version reflects actual version number without prelease since that not allowed in its struct -->
13-
<FileVersion>$(CurrentAssemblyFileVersion)</FileVersion>
14-
15-
<DefineConstants Condition="'$(TargetFramework)'=='netstandard2.0'">$(DefineConstants);DOTNETCORE</DefineConstants>
16-
<DefineConstants Condition="'$(TargetFramework)'=='netcoreapp2.0'">$(DefineConstants);DOTNETCORE</DefineConstants>
17-
<DefineConstants Condition="'$(TargetFramework)'=='netcoreapp2.1'">$(DefineConstants);DOTNETCORE</DefineConstants>
18-
19-
<RepoUri>https://raw.githubusercontent.com/elastic/elasticsearch-net</RepoUri>
20-
<Authors>Elasticsearch BV</Authors>
21-
<Copyright>Elasticsearch BV</Copyright>
22-
<PackageProjectUrl>https://github.com/elastic/elasticsearch-net</PackageProjectUrl>
23-
<PackageLicenseUrl>https://github.com/elastic/elasticsearch-net/blob/master/license.txt</PackageLicenseUrl>
24-
<ReleaseNotes>See https://github.com/elastic/elasticsearch-net/releases</ReleaseNotes>
25-
<PackageIconUrl>https://raw.githubusercontent.com/elastic/elasticsearch-net/master/build/nuget-icon.png</PackageIconUrl>
3+
<LangVersion>Latest</LangVersion>
264
</PropertyGroup>
275
</Project>

src/Elasticsearch.Net/Connection/CertificateValidations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static Func<object, X509Certificate, X509Chain, SslPolicyErrors, bool> Au
5757

5858
private static X509Certificate2 to2(X509Certificate certificate)
5959
{
60-
#if !FEATURE_HTTPWEBREQUEST
60+
#if DOTNETCORE
6161
return new X509Certificate2(certificate.Export(X509ContentType.Cert));
6262
#else
6363
return new X509Certificate2(certificate);

src/Elasticsearch.Net/Connection/ClientCertificate.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ THE SOFTWARE.
3636

3737
namespace Elasticsearch.Net
3838
{
39-
//.NET removed the setter for PrivateKey for X509Certificate, you'll have to manually convert to pfx/p12 or add the key to the machine store
40-
#if FEATURE_HTTPWEBREQUEST
39+
//.NET core removed the setter for PrivateKey for X509Certificate, you'll have to manually convert to pfx/p12 or add the key to the machine store
40+
#if !DOTNETCORE
4141

4242
public class ClientCertificate
4343
{

src/Elasticsearch.Net/Connection/HttpConnection-CoreFx.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if !FEATURE_HTTPWEBREQUEST
1+
#if DOTNETCORE
22
using System;
33
using System.Collections.Concurrent;
44
using System.Collections.Generic;
@@ -29,6 +29,8 @@ internal class WebProxy : IWebProxy
2929
public bool IsBypassed(Uri host) => host.IsLoopback;
3030
}
3131

32+
33+
/// <summary> The default IConnection implementation. Uses <see cref="HttpClient"/>.</summary>
3234
public class HttpConnection : IConnection
3335
{
3436
private readonly object _lock = new object();

0 commit comments

Comments
 (0)