Skip to content

Commit

Permalink
Merge pull request #192 from mauroservienti/multi-targeting-1.2
Browse files Browse the repository at this point in the history
[1.2] Add multi-targeting support .NET Core 3.1/.NET Framework 4.8
  • Loading branch information
mauroservienti authored Oct 16, 2021
2 parents ae4a68d + 2c2194f commit ef60867
Show file tree
Hide file tree
Showing 13 changed files with 196 additions and 28 deletions.
39 changes: 27 additions & 12 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
version: '{build}'
image: ubuntu2004
image:
- ubuntu2004
- Visual Studio 2019

skip_branch_with_pr: true
pull_requests:
Expand All @@ -15,17 +17,6 @@ branches:
- /release-.*/
- /^\d+\.\d+\.\d+(-\S*)?$/

skip_commits:
files:
- '**/*.source.md'

before_build:
- sh: sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
- sh: sudo chmod +x /usr/local/bin/docker-compose

build_script:
- sh: ./build.sh

artifacts:
- path: ./**/*.nupkg
type: NuGetPackage
Expand All @@ -34,3 +25,27 @@ artifacts:

test: off
deploy: off

for:
-
matrix:
only:
- image: ubuntu2004

before_build:
- sh: sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
- sh: sudo chmod +x /usr/local/bin/docker-compose

build_script:
- sh: ./build.sh

-
matrix:
only:
- image: Visual Studio 2019

before_build:
- cmd: docker-switch-linux

build_script:
- cmd: .\build.cmd
2 changes: 1 addition & 1 deletion src/MyOtherService/MyOtherService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFrameworks>netcoreapp3.1;net48</TargetFrameworks>
<LangVersion>latest</LangVersion>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/MyService/MyService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFrameworks>netcoreapp3.1;net48</TargetFrameworks>
<LangVersion>latest</LangVersion>
</PropertyGroup>

Expand Down
20 changes: 18 additions & 2 deletions src/MySystem.AcceptanceTests/DockerCompose.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
using System;
using System.Net.Http;
using System.Threading.Tasks;
using static SimpleExec.Command;

#if NETCOREAPP
using System.Net.Http;
#endif

#if NET48
using System.Net;
#endif

namespace MySystem.AcceptanceTests
{
public static class DockerCompose
Expand All @@ -16,9 +23,18 @@ static async Task<bool> statusChecker()
{
try
{
var managementUrl = "http://localhost:15672/";
#if NETCOREAPP
using var client = new HttpClient();
var response = await client.GetAsync("http://localhost:15672/");
var response = await client.GetAsync(managementUrl);
return response.IsSuccessStatusCode;
#endif

#if NET48
var request = HttpWebRequest.Create(managementUrl);
var response = await request.GetResponseAsync();
return ((HttpWebResponse)response).StatusCode == HttpStatusCode.OK;
#endif
}
catch
{
Expand Down
6 changes: 5 additions & 1 deletion src/MySystem.AcceptanceTests/MySystem.AcceptanceTests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFrameworks>netcoreapp3.1;net48</TargetFrameworks>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand All @@ -15,6 +15,10 @@
<PackageReference Include="SimpleExec" Version="6.4.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net48' ">
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.20" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\MyOtherService\MyOtherService.csproj" />
<ProjectReference Include="..\MyService\MyService.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netcoreapp3.1;net48</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFrameworks>netcoreapp3.1;net48</TargetFrameworks>
<LangVersion>latest</LangVersion>
</PropertyGroup>

Expand Down
7 changes: 7 additions & 0 deletions src/NServiceBus.IntegrationTesting.Tests/API/ApiApprovals.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Runtime.CompilerServices;
using ApprovalTests;
using ApprovalTests.Namers;
using ApprovalTests.Reporters;
using NUnit.Framework;
using PublicApiGenerator;
Expand All @@ -11,6 +12,12 @@ public class APIApprovals
[Test]
[UseReporter(typeof(DiffReporter))]
[MethodImpl(MethodImplOptions.NoInlining)]
#if NETCOREAPP
[UseApprovalSubdirectory("NETCOREAPP")]
#endif
#if NET48
[UseApprovalSubdirectory("NET48")]
#endif
public void Approve_API()
{
var publicApi = typeof(IntegrationScenarioContext).Assembly.GeneratePublicApi();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/mauroservienti/NServiceBus.IntegrationTesting.git")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("NServiceBus.IntegrationTesting.Tests")]
[assembly: System.Runtime.Versioning.TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName=".NET Framework 4.8")]
namespace NServiceBus.IntegrationTesting
{
public class EmptyTestCompletionHandler : NServiceBus.IntegrationTesting.IHandleTestCompletion
{
public EmptyTestCompletionHandler() { }
public System.Threading.Tasks.Task OnTestCompleted(NServiceBus.AcceptanceTesting.Support.RunSummary summary) { }
}
public static class EndpointConfigurationExtensions
{
public static void RegisterRequiredPipelineBehaviors(this NServiceBus.EndpointConfiguration builder, string endpointName, NServiceBus.IntegrationTesting.IntegrationScenarioContext integrationScenarioContext) { }
public static void RegisterScenarioContext(this NServiceBus.EndpointConfiguration builder, NServiceBus.AcceptanceTesting.ScenarioContext scenarioContext) { }
}
public abstract class EndpointTemplate : NServiceBus.AcceptanceTesting.Support.IEndpointSetupTemplate
{
protected EndpointTemplate() { }
public System.Threading.Tasks.Task<NServiceBus.EndpointConfiguration> GetConfiguration(NServiceBus.AcceptanceTesting.Support.RunDescriptor runDescriptor, NServiceBus.AcceptanceTesting.Support.EndpointCustomizationConfiguration endpointCustomizationConfiguration, System.Action<NServiceBus.EndpointConfiguration> configurationBuilderCustomization) { }
protected abstract System.Threading.Tasks.Task<NServiceBus.EndpointConfiguration> OnGetConfiguration(NServiceBus.AcceptanceTesting.Support.RunDescriptor runDescriptor, NServiceBus.AcceptanceTesting.Support.EndpointCustomizationConfiguration endpointCustomizationConfiguration, System.Action<NServiceBus.EndpointConfiguration> configurationBuilderCustomization);
}
public class EndpointTemplate<T> : NServiceBus.IntegrationTesting.EndpointTemplate
where T : NServiceBus.EndpointConfiguration, new ()
{
public EndpointTemplate() { }
protected override System.Threading.Tasks.Task<NServiceBus.EndpointConfiguration> OnGetConfiguration(NServiceBus.AcceptanceTesting.Support.RunDescriptor runDescriptor, NServiceBus.AcceptanceTesting.Support.EndpointCustomizationConfiguration endpointCustomizationConfiguration, System.Action<NServiceBus.EndpointConfiguration> configurationBuilderCustomization) { }
}
public class EndpointTemplate<T, C> : NServiceBus.IntegrationTesting.EndpointTemplate<T>
where T : NServiceBus.EndpointConfiguration, new ()
where C : NServiceBus.IntegrationTesting.IHandleTestCompletion, new ()
{
public EndpointTemplate() { }
protected override System.Threading.Tasks.Task<NServiceBus.EndpointConfiguration> OnGetConfiguration(NServiceBus.AcceptanceTesting.Support.RunDescriptor runDescriptor, NServiceBus.AcceptanceTesting.Support.EndpointCustomizationConfiguration endpointConfiguration, System.Action<NServiceBus.EndpointConfiguration> configurationBuilderCustomization) { }
}
public class GenericHostEndpointBehaviorBuilder<TContext>
where TContext : NServiceBus.AcceptanceTesting.ScenarioContext
{
public GenericHostEndpointBehaviorBuilder() { }
public System.Collections.Generic.IList<NServiceBus.AcceptanceTesting.Support.IWhenDefinition> Whens { get; }
public NServiceBus.IntegrationTesting.GenericHostEndpointBehaviorBuilder<TContext> When(System.Func<NServiceBus.IMessageSession, System.Threading.Tasks.Task> action) { }
public NServiceBus.IntegrationTesting.GenericHostEndpointBehaviorBuilder<TContext> When(System.Func<NServiceBus.IMessageSession, TContext, System.Threading.Tasks.Task> action) { }
public NServiceBus.IntegrationTesting.GenericHostEndpointBehaviorBuilder<TContext> When(System.Func<TContext, System.Threading.Tasks.Task<bool>> condition, System.Func<NServiceBus.IMessageSession, System.Threading.Tasks.Task> action) { }
public NServiceBus.IntegrationTesting.GenericHostEndpointBehaviorBuilder<TContext> When(System.Func<TContext, System.Threading.Tasks.Task<bool>> condition, System.Func<NServiceBus.IMessageSession, TContext, System.Threading.Tasks.Task> action) { }
public NServiceBus.IntegrationTesting.GenericHostEndpointBehaviorBuilder<TContext> When(System.Predicate<TContext> condition, System.Func<NServiceBus.IMessageSession, System.Threading.Tasks.Task> action) { }
public NServiceBus.IntegrationTesting.GenericHostEndpointBehaviorBuilder<TContext> When(System.Predicate<TContext> condition, System.Func<NServiceBus.IMessageSession, TContext, System.Threading.Tasks.Task> action) { }
}
public class HandlerInvocation : NServiceBus.IntegrationTesting.Invocation
{
public HandlerInvocation() { }
public System.Type HandlerType { get; }
}
public interface IHandleTestCompletion
{
System.Threading.Tasks.Task OnTestCompleted(NServiceBus.AcceptanceTesting.Support.RunSummary summary);
}
public class IntegrationScenarioContext : NServiceBus.AcceptanceTesting.ScenarioContext
{
public IntegrationScenarioContext() { }
public System.Collections.Generic.IEnumerable<NServiceBus.IntegrationTesting.HandlerInvocation> InvokedHandlers { get; }
public System.Collections.Generic.IEnumerable<NServiceBus.IntegrationTesting.SagaInvocation> InvokedSagas { get; }
public System.Collections.Generic.IEnumerable<NServiceBus.IntegrationTesting.OutgoingMessageOperation> OutgoingMessageOperations { get; }
public bool HandlerWasInvoked<THandler>() { }
public bool HasFailedMessages() { }
public bool HasHandlingErrors() { }
public bool MessageWasProcessed<TMessage>() { }
public bool MessageWasProcessedByHandler<TMessage, THandler>() { }
public bool MessageWasProcessedBySaga<TMessage, TSaga>() { }
public void RegisterTimeoutRescheduleRule<TTimeout>(System.Func<object, NServiceBus.DelayedDelivery.DoNotDeliverBefore, NServiceBus.DelayedDelivery.DoNotDeliverBefore> rule) { }
public bool SagaWasCompleted<TSaga>()
where TSaga : NServiceBus.Saga { }
public bool SagaWasInvoked<TSaga>()
where TSaga : NServiceBus.Saga { }
}
public abstract class Invocation
{
protected Invocation() { }
public string EndpointName { get; }
public System.Exception HandlingError { get; }
public object Message { get; }
public System.Type MessageType { get; }
}
public abstract class OutgoingMessageOperation
{
protected OutgoingMessageOperation() { }
public System.Collections.Generic.Dictionary<string, string> MessageHeaders { get; }
public string MessageId { get; }
public object MessageInstance { get; }
public System.Type MessageType { get; }
public System.Exception OperationError { get; }
public string SenderEndpoint { get; }
}
public class PublishOperation : NServiceBus.IntegrationTesting.OutgoingMessageOperation
{
public PublishOperation() { }
}
public class ReplyOperation : NServiceBus.IntegrationTesting.OutgoingMessageOperation
{
public ReplyOperation() { }
}
public class RequestTimeoutOperation : NServiceBus.IntegrationTesting.SendOperation
{
public RequestTimeoutOperation() { }
public string SagaId { get; }
public string SagaTypeAssemblyQualifiedName { get; }
}
public class SagaInvocation : NServiceBus.IntegrationTesting.Invocation
{
public SagaInvocation() { }
public bool IsCompleted { get; }
public bool IsNew { get; }
public bool NotFound { get; }
public NServiceBus.IContainSagaData SagaData { get; }
public System.Type SagaType { get; }
}
public static class ScenarioWithEndpointBehaviorExtensions
{
public static NServiceBus.AcceptanceTesting.Support.IScenarioWithEndpointBehavior<TContext> WithGenericHostEndpoint<TContext>(this NServiceBus.AcceptanceTesting.Support.IScenarioWithEndpointBehavior<TContext> scenarioWithEndpoint, string endpointName, System.Func<System.Action<NServiceBus.EndpointConfiguration>, Microsoft.Extensions.Hosting.IHost> hostBuilder, System.Action<NServiceBus.IntegrationTesting.GenericHostEndpointBehaviorBuilder<TContext>> behavior = null)
where TContext : NServiceBus.AcceptanceTesting.ScenarioContext { }
}
public class SendOperation : NServiceBus.IntegrationTesting.OutgoingMessageOperation
{
public SendOperation() { }
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/mauroservienti/NServiceBus.IntegrationTesting.git")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("NServiceBus.IntegrationTesting.Tests")]
[assembly: System.Runtime.Versioning.TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName="")]
[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v3.1", FrameworkDisplayName="")]
namespace NServiceBus.IntegrationTesting
{
public class EmptyTestCompletionHandler : NServiceBus.IntegrationTesting.IHandleTestCompletion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFrameworks>netcoreapp3.1;net48</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand All @@ -13,7 +13,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="ApprovalTests" Version="5.4.5" />
<PackageReference Include="ApprovalTests" Version="5.7.1" />
<PackageReference Include="PublicApiGenerator" Version="10.2.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netcoreapp3.1;net48</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -24,13 +24,13 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="[3.1.19, 5.0.0)" />
<PackageReference Include="NServiceBus" Version="[7.4.3, 8.0.0)" />
<PackageReference Include="NServiceBus.AcceptanceTesting" Version="[7.4.3, 8.0.0)" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="[3.1.19, 5.0.0)" />
<PackageReference Include="NServiceBus" Version="[7.4.3, 8.0.0)" />
<PackageReference Include="NServiceBus.AcceptanceTesting" Version="[7.4.3, 8.0.0)" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="MinVer" Version="2.4.0">
<PackageReference Include="MinVer" Version="2.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
4 changes: 3 additions & 1 deletion targets/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public static void Main(string[] args)
var sourceDir = "src";

var sdk = new DotnetSdkManager();
var isUnix = Environment.OSVersion.Platform == PlatformID.Unix;
var unixFx = "netcoreapp3.1";

Target("default", DependsOn("test"));

Expand All @@ -21,7 +23,7 @@ public static void Main(string[] args)

Target("test", DependsOn("build"),
Directory.EnumerateFiles(sourceDir, "*Tests.csproj", SearchOption.AllDirectories),
proj => Run(sdk.GetDotnetCliPath(), $"test \"{proj}\" --configuration Release --no-build"));
proj => Run(sdk.GetDotnetCliPath(), $"test \"{proj}\" {(isUnix ? "--framework " + unixFx : "")} --configuration Release --no-build"));

RunTargetsAndExit(args);
}
Expand Down

0 comments on commit ef60867

Please sign in to comment.