Skip to content

Commit

Permalink
Added support for NetStandard2 (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
snakefoot authored Sep 10, 2023
2 parents e914442 + f979181 commit def4452
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 19 deletions.
4 changes: 3 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
version: 5.0.0.{build}
image: Visual Studio 2019
image: Visual Studio 2022
configuration: Release
platform: Any CPU
nuget:
disable_publish_on_pr: true
build_script:
- ps: msbuild /t:restore,pack /p:Configuration=Release /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg /p:ContinuousIntegrationBuild=true /p:EmbedUntrackedSources=true /p:PublishRepositoryUrl=true /verbosity:minimal
test_script:
Expand Down
21 changes: 10 additions & 11 deletions src/NLog.MSMQ/NLog.MSMQ.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks Condition=" '$(TargetFrameworks)' == '' ">net46;net45;net35</TargetFrameworks>
<TargetFrameworks Condition=" '$(TargetFrameworks)' == '' ">net46;net45;net35;netstandard2.0</TargetFrameworks>
<RootNamespace>NLog</RootNamespace>

<VersionPrefix>5.0.0</VersionPrefix>
Expand All @@ -22,8 +22,8 @@
<Copyright>Copyright (c) 2004-$(CurrentYear) NLog Project - https://nlog-project.org/ </Copyright>

<PackageReleaseNotes>
Docs:
https://github.com/NLog/NLog/wiki/MSMQ-target
Docs:
https://github.com/NLog/NLog/wiki/MSMQ-target
</PackageReleaseNotes>
<PackageTags>NLog;MSMQ;logging;log</PackageTags>
<PackageIcon>N.png</PackageIcon>
Expand All @@ -45,42 +45,41 @@
<Title>MSMQ target for NLog - .NET Framework 4.6</Title>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
<DebugType Condition=" '$(Configuration)' == 'Debug' ">Full</DebugType>
<DefineConstants>$(DefineConstants)</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Title>MSMQ target for NLog - .NET Framework 4.5</Title>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
<DebugType Condition=" '$(Configuration)' == 'Debug' ">Full</DebugType>
<DefineConstants>$(DefineConstants)</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net35' ">
<Title>MSMQ target for NLog - .NET Framework 3.5</Title>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
<DebugType Condition=" '$(Configuration)' == 'Debug' ">Full</DebugType>
<DefineConstants>$(DefineConstants)</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="NLog" Version="5.0.0" />
<PackageReference Include="NLog" Version="5.2.2" />
</ItemGroup>

<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<ItemGroup Condition="'$(TargetFramework)' != 'netstandard2.0'">
<Reference Include="System.Messaging" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="MSMQ.Messaging" Version="1.0.4" />
</ItemGroup>

<PropertyGroup>
<AssemblyTitle>$(Title)</AssemblyTitle>
</PropertyGroup>

<ItemGroup>
<None Include="N.png" Pack="true" PackagePath="" Visible="false" />
</ItemGroup>

<Target Name="DownloadMissingContent" BeforeTargets="GenerateNuspec">
<DownloadFile SourceUrl="https://nlog-project.org/N.png" DestinationFolder="$(MSBuildThisFileDirectory)" />
</Target>
Expand Down
2 changes: 2 additions & 0 deletions src/NLog.MSMQ/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
using System.Security;

[assembly: AssemblyCulture("")]
#if !NETSTANDARD
[assembly: CLSCompliant(true)]
#endif
[assembly: ComVisible(false)]
[assembly: InternalsVisibleTo("NLog.MSMQ.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100ef8eab4fbdeb511eeb475e1659fe53f00ec1c1340700f1aa347bf3438455d71993b28b1efbed44c8d97a989e0cb6f01bcb5e78f0b055d311546f63de0a969e04cf04450f43834db9f909e566545a67e42822036860075a1576e90e1c43d43e023a24c22a427f85592ae56cac26f13b7ec2625cbc01f9490d60f16cfbb1bc34d9")]
[assembly: AllowPartiallyTrustedCallers]
Expand Down
8 changes: 6 additions & 2 deletions src/NLog.MSMQ/Targets/MessageQueueTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@

namespace NLog.Targets
{
#if NETSTANDARD
using MSMQ.Messaging;
#else
using System.Messaging;
#endif
using System.Text;
using NLog.Config;
using NLog.Layouts;
Expand All @@ -60,7 +64,7 @@ namespace NLog.Targets
[Target("MSMQ")]
public class MessageQueueTarget : TargetWithLayout
{
private const MessagePriority MessagePriority = System.Messaging.MessagePriority.Normal;
private const MessagePriority DefaultMessagePriority = MessagePriority.Normal;

/// <summary>
/// Initializes a new instance of the <see cref="MessageQueueTarget"/> class.
Expand Down Expand Up @@ -187,7 +191,7 @@ protected virtual Message PrepareMessage(LogEventInfo logEvent)
}

msg.Recoverable = Recoverable;
msg.Priority = MessagePriority;
msg.Priority = DefaultMessagePriority;

if (UseXmlEncoding)
{
Expand Down
6 changes: 5 additions & 1 deletion tests/NLog.MSMQ.Tests/MessageQueueTargetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@
// THE POSSIBILITY OF SUCH DAMAGE.
//

namespace NLog.MSMQ.Tests
namespace NLog.MessageQueue.Tests
{
using System.Collections.Generic;
#if NETFRAMEWORK
using System.Messaging;
#else
using MSMQ.Messaging;
#endif
using NLog.Targets;
using Xunit;

Expand Down
10 changes: 6 additions & 4 deletions tests/NLog.MSMQ.Tests/NLog.MSMQ.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net452;net461</TargetFrameworks>
<TargetFrameworks>net452;net461;net6.0</TargetFrameworks>
<IsPackable>false</IsPackable>

<AssemblyOriginatorKeyFile>../NLogTests.snk</AssemblyOriginatorKeyFile>
Expand All @@ -10,11 +10,13 @@
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
</PropertyGroup>

<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'netstandard2.0'">
<Reference Include="System.Messaging" />
</ItemGroup>

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
</ItemGroup>

Expand Down

0 comments on commit def4452

Please sign in to comment.