Skip to content

Commit

Permalink
Removed Xamarin-platforms and added NET7 and NET8 (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
snakefoot authored Jan 9, 2024
1 parent 5623e89 commit fbe5fdd
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 45 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,5 @@ MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/

.idea/
2 changes: 2 additions & 0 deletions NLog.Targets.MauiLog.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ VisualStudioVersion = 17.3.32804.467
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EA9503EA-0938-497B-ACBF-5907B66D56A1}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
appveyor.yml = appveyor.yml
global.json = global.json
README.md = README.md
update-global-json.ps1 = update-global-json.ps1
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NLog.Targets.MauiLog", "src\NLog.Targets.MauiLog\NLog.Targets.MauiLog.csproj", "{F7C81AB8-6833-449D-80E3-68CEC129E692}"
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ NLog Target for debugging on MAUI / Xamarin Mobile Platforms:
- `Install-Package NLog.Targets.MauiLog`
- `Install-Package NLog.Extensions.Logging`

or in your csproj:
or in your csproj (Use ver. 8 for NET8, and ver. 7 for NET7 etc.):

```xml
<PackageReference Include="NLog.Targets.MauiLog" Version="5.*" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.*" />
<PackageReference Include="NLog.Targets.MauiLog" Version="8.*" />
<PackageReference Include="NLog.Extensions.Logging" Version="8.*" />
```

2) **Add NLog to the MauiApp**
Expand Down
14 changes: 10 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
version: 5.0.0.{build}
image: Previous Visual Studio 2022
version: 6.0.0.{build}
image: Visual Studio 2022
configuration: Release
platform: Any CPU
nuget:
disable_publish_on_pr: true
build_script:
- ps: dotnet workload install maui macos android ios maccatalyst
- 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
- ps: dotnet tool install -g Redth.Net.Maui.Check
- ps: ./update-global-json.ps1 7.0.400
- ps: msbuild src/NLog.Targets.MauiLog/NLog.Targets.MauiLog.csproj /t:restore,pack /p:targetFrameworks='"net7.0;net7.0-ios;net7.0-macos;net7.0-android;net7.0-maccatalyst"' /p:VersionPrefix=7.0.0 /p:AssemblyVersion=7.0.0.0 /p:Configuration=Release /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg /p:EmbedUntrackedSources=true /p:PublishRepositoryUrl=true /verbosity:minimal
- ps: ./update-global-json.ps1 6.0.400
- ps: msbuild src/NLog.Targets.MauiLog/NLog.Targets.MauiLog.csproj /t:restore,pack /p:targetFrameworks='"net6.0;net6.0-ios;net6.0-macos;net6.0-android;net6.0-maccatalyst"' /p:VersionPrefix=6.0.0 /p:AssemblyVersion=6.0.0.0 /p:Configuration=Release /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg /p:EmbedUntrackedSources=true /p:PublishRepositoryUrl=true /verbosity:minimal
- ps: ./update-global-json.ps1 8.0.100
- ps: msbuild src/NLog.Targets.MauiLog/NLog.Targets.MauiLog.csproj /t:restore,pack /p:targetFrameworks='"net8.0;net8.0-ios;net8.0-macos;net8.0-android;net8.0-maccatalyst"' /p:VersionPrefix=8.0.0 /p:AssemblyVersion=8.0.0.0 /p:Configuration=Release /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg /p:EmbedUntrackedSources=true /p:PublishRepositoryUrl=true /verbosity:minimal
- ps: msbuild /t:restore,build /p:VersionPrefix=8.0.0 /p:Configuration=Release /verbosity:minimal
artifacts:
- path: '**\NLog.*.nupkg'
- path: '**\NLog.*.snupkg'
Expand Down
27 changes: 19 additions & 8 deletions examples/MauiApp2/MauiApp2.csproj
Original file line number Diff line number Diff line change
@@ -1,30 +1,39 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>

<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
<!-- <TargetFrameworks>$(TargetFrameworks);net8.0-tizen</TargetFrameworks> -->

<!-- Note for MacCatalyst:
The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
When specifying both architectures, use the plural <RuntimeIdentifiers> instead of the singular <RuntimeIdentifier>.
The Mac App Store will NOT accept apps with ONLY maccatalyst-arm64 indicated;
either BOTH runtimes must be indicated or ONLY macatalyst-x64. -->
<!-- For example: <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers> -->

<OutputType>Exe</OutputType>
<RootNamespace>MauiApp2</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<CheckEolWorkloads>false</CheckEolWorkloads>
<IsPackable>false</IsPackable>

<!-- Display name -->
<ApplicationTitle>MauiApp2</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.companyname.mauiapp2</ApplicationId>
<ApplicationIdGuid>708DDDE0-C95D-4905-84B0-4237AEF98BDA</ApplicationIdGuid>

<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
Expand All @@ -51,10 +60,12 @@

<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.3" />
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\NLog.Targets.MauiLog\NLog.Targets.MauiLog.csproj" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.3" />
<ProjectReference Include="..\..\src\NLog.Targets.MauiLog\NLog.Targets.MauiLog.csproj" />
</ItemGroup>
</Project>
14 changes: 12 additions & 2 deletions examples/MauiApp2/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@
using CommunityToolkit.Mvvm.Input;
using System.Collections.ObjectModel;
using System.ComponentModel;
using Microsoft.Extensions.Logging;

namespace MauiApp2.ViewModel;

public partial class MainViewModel : ObservableObject
{
IConnectivity connectivity;
public MainViewModel(IConnectivity connectivity)
private readonly IConnectivity connectivity;
private readonly ILogger<MainViewModel> _logger;

public MainViewModel(IConnectivity connectivity, ILogger<MainViewModel> logger)
{
Items = new ObservableCollection<string>();
this.connectivity = connectivity;
this._logger = logger;
}

[ObservableProperty]
Expand Down Expand Up @@ -49,6 +53,12 @@ void Delete(string s)
[RelayCommand]
async Task Tap(string s)
{
_logger.LogTrace("Trace");
_logger.LogDebug("Debug");
_logger.LogInformation("Info");
_logger.LogWarning("Warn");
_logger.LogError("Error");
_logger.LogCritical("Critical");
await Shell.Current.GoToAsync($"{nameof(DetailPage)}?Text={s}");
}

Expand Down
8 changes: 2 additions & 6 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
{
"sdk": {
"version": "6.0.400",
"version": "8.0.100",
"rollForward": "latestMinor"
},
"msbuild-sdks": {
"MSBuild.Sdk.Extras": "3.0.44",
"Microsoft.Build.NoTargets": "3.3.0"
}
}
4 changes: 2 additions & 2 deletions src/NLog.Targets.MauiLog/Config/SetupBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace NLog
public static class SetupBuilderExtensions
{
/// <summary>
/// Register the NLog.Web LayoutRenderers before loading NLog config
/// Register the NLog.Target.MauiLog extensions before loading NLog config
/// </summary>
public static ISetupBuilder RegisterMauiLog(this ISetupBuilder setupBuilder)
{
Expand All @@ -18,7 +18,7 @@ public static ISetupBuilder RegisterMauiLog(this ISetupBuilder setupBuilder)
}

/// <summary>
/// Register the NLog.Web LayoutRenderers before loading NLog config
/// Register the NLog.Target.MauiLog extensions before loading NLog config
/// </summary>
public static ISetupBuilder RegisterMauiLog(this ISetupBuilder setupBuilder, UnhandledExceptionEventHandler unhandledException)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace NLog
public static class SetupExtensionsBuilderExtensions
{
/// <summary>
/// Register the NLog.Web LayoutRenderers
/// Register the NLog.Target.MauiLog extensions before loading NLog config
/// </summary>
public static ISetupExtensionsBuilder RegisterMauiLog(this ISetupExtensionsBuilder setupBuilder)
{
Expand Down
37 changes: 18 additions & 19 deletions src/NLog.Targets.MauiLog/NLog.Targets.MauiLog.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<Project Sdk="MSBuild.Sdk.Extras">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks Condition="'$(ContinuousIntegrationBuild)' != 'true'">netstandard2.0;net461</TargetFrameworks>
<TargetFrameworks Condition="'$(ContinuousIntegrationBuild)' == 'true'">netstandard2.0;Xamarin.iOS10;Xamarin.Mac20;MonoAndroid90;net6.0-ios;net6.0-macos;net6.0-android;net6.0-maccatalyst</TargetFrameworks>
<VersionPrefix>5.2.1</VersionPrefix>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AppVeyorBuildNumber>$(APPVEYOR_BUILD_NUMBER)</AppVeyorBuildNumber>
<AppVeyorBuildNumber Condition="'$(AppVeyorBuildNumber)' == ''">0</AppVeyorBuildNumber>
<FileVersion>$(VersionPrefix).$(AppVeyorBuildNumber)</FileVersion>

<Title>NLog.Targets.MauiLog</Title>
<TargetFrameworks Condition="'$(TargetFrameworks)' == '' And '$(AppVeyorBuildNumber)' == ''">net8.0</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetFrameworks)' == ''">net8.0;net8.0-ios;net8.0-macos;net8.0-android;net8.0-maccatalyst</TargetFrameworks>
<FileVersion Condition="'$(AppVeyorBuildNumber)' != ''">$(VersionPrefix).$(AppVeyorBuildNumber)</FileVersion>

<Title>NLog.Targets.MauiLog for $(TargetFramework)</Title>
<AssemblyTitle>$(Title)</AssemblyTitle>
<Company>NLog</Company>
<Description>NLog MauiLog Target for writing to Apple Unified Logging / Android.Util.Log for LogCat</Description>
<RepositoryType>git</RepositoryType>
Expand All @@ -20,9 +18,7 @@
<PackageLicenseExpression>BSD-3-Clause</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageReleaseNotes>
- Added support for UnhandledExceptionEventHandler in RegisterMauiLog
- Updated to NLog v5.2.2
- Added nuget-package README.md
- Removed Xamarin TargetFrameworks

See https://github.com/NLog/NLog.Targets.MauiLog for documentation of NLog targets for MAUI
</PackageReleaseNotes>
Expand All @@ -32,7 +28,9 @@ See https://github.com/NLog/NLog.Targets.MauiLog for documentation of NLog targe
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<IsTrimmable>true</IsTrimmable>
<TrimMode>copyused</TrimMode>
<CheckEolWorkloads>false</CheckEolWorkloads>
<SingleProject>true</SingleProject>
</PropertyGroup>

<ItemGroup>
Expand All @@ -49,24 +47,25 @@ See https://github.com/NLog/NLog.Targets.MauiLog for documentation of NLog targe
<DownloadFile SourceUrl="https://nlog-project.org/N.png" DestinationFolder="$(MSBuildThisFileDirectory)" />
</Target>

<PropertyGroup Condition=" '$(TargetFramework)' == 'MonoAndroid90' Or '$(TargetFramework)' == 'net6.0-android' ">
<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
<DefineConstants>$(DefineConstants);__ANDROID__</DefineConstants>
<SupportedOSPlatformVersion>21.0</SupportedOSPlatformVersion>
<TargetPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-android'">33</TargetPlatformVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'Xamarin.iOS10' Or '$(TargetFramework)' == 'Xamarin.Mac20' Or '$(TargetFramework)' == 'net6.0-ios' Or '$(TargetFramework)' == 'net6.0-macos' Or '$(TargetFramework)' == 'net6.0-maccatalyst' ">
<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios' Or $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst' ">
<DefineConstants>$(DefineConstants);__APPLE__</DefineConstants>
<SupportedOSPlatformVersion>10.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-macos'">10.14</SupportedOSPlatformVersion>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'Xamarin.iOS10' Or '$(TargetFramework)' == 'Xamarin.Mac20' ">
<Reference Include="netstandard" />
</ItemGroup>
<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'macos' ">
<DefineConstants>$(DefineConstants);__APPLE__</DefineConstants>
<SupportedOSPlatformVersion>10.14</SupportedOSPlatformVersion>
</PropertyGroup>

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

</Project>
7 changes: 7 additions & 0 deletions update-global-json.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'{ "sdk": { "version": "' + $args[0] +'", "rollForward": "latestMinor" } }' | Out-File -FilePath global.json -Encoding utf8

dotnet workload install maui macos android ios maccatalyst

maui-check --fix --non-interactive

exit 0

0 comments on commit fbe5fdd

Please sign in to comment.