Skip to content

Commit

Permalink
fix: #282 fix .NET7-Ocelot19.* and .NET8-Ocelot20.* bug (#283)
Browse files Browse the repository at this point in the history
* fix: #282 fix .NET7-Ocelot19.* and .NET8-Ocelot20.* bug

* fix: Fix the bug that specifies the wrong .NET version in the workflow and fix the bug of the wrong .NET version number in the test project.
  • Loading branch information
MateralCMX authored Nov 21, 2023
1 parent df98d79 commit b56a5c8
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup .NET Core if needed
uses: actions/setup-dotnet@v2
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Build
run: dotnet build ./MMLib.SwaggerForOcelot.sln --configuration Release
- name: Test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- name: Setup .NET Core if needed
uses: actions/setup-dotnet@v2
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Build
run: dotnet build ./MMLib.SwaggerForOcelot.sln --configuration Release
- name: Test
Expand Down
16 changes: 10 additions & 6 deletions src/MMLib.SwaggerForOcelot/MMLib.SwaggerForOcelot.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<Version>7.0.1</Version>
<Authors>Milan Martiniak</Authors>
<Company>MMLib</Company>
Expand All @@ -17,23 +16,28 @@
<LangVersion>preview</LangVersion>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>bin\Release\MMLib.SwaggerForOcelot.xml</DocumentationFile>
<OutputPath>bin\Release</OutputPath>
</PropertyGroup>

<ItemGroup>
<None Include="icon.png" Pack="true" PackagePath="" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Kros.Utils" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Ocelot" Version="19.0.2" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.5.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Ocelot" Version="18.*" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Ocelot" Version="19.*" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Ocelot" Version="20.*" />
</ItemGroup>
<ItemGroup>
<None Include="../../README.md" Pack="true" PackagePath="\" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,11 @@ private async Task<Uri> GetSwaggerUri(SwaggerEndPointConfig endPoint, RouteOptio
{
throw new InvalidOperationException(GetErrorMessage(endPoint));
}

#if NET6_0
ServiceHostAndPort service = (await serviceProvider.Data.Get()).FirstOrDefault()?.HostAndPort;
#else
ServiceHostAndPort service = (await serviceProvider.Data.GetAsync()).FirstOrDefault()?.HostAndPort;
#endif

if (service is null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<PublishSingleFile>true</PublishSingleFile>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Properties\**" />
<EmbeddedResource Remove="Properties\**" />
<None Remove="Properties\**" />
</ItemGroup>
<ItemGroup>
<None Remove="Resources\AggregatesOpenApiResource.json" />
<None Remove="Tests\BasicConfigurationWithSchemaInHostOverride.json" />
Expand Down Expand Up @@ -70,7 +75,4 @@
<ItemGroup>
<ProjectReference Include="..\..\src\MMLib.SwaggerForOcelot\MMLib.SwaggerForOcelot.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private static SwaggerServiceDiscoveryProvider CreateProvider(Service service =
options.CurrentValue.Returns(new FileConfiguration());

IServiceDiscoveryProvider serviceProvider = Substitute.For<IServiceDiscoveryProvider>();
serviceProvider.Get().Returns(new List<Service>() { service });
serviceProvider.GetAsync().Returns(new List<Service>() { service });
var response = new OkResponse<IServiceDiscoveryProvider>(serviceProvider);

serviceDiscovery.Get(Arg.Any<ServiceProviderConfiguration>(), Arg.Any<DownstreamRoute>()).Returns(response);
Expand Down

0 comments on commit b56a5c8

Please sign in to comment.