Skip to content

Commit

Permalink
feat (Laerdal.Builder.targets): we now co-generate a net8-only build …
Browse files Browse the repository at this point in the history
…of the Laerdal.McuMgr nuget with the *-force-dud postfix in the version to assist people testing UI apps using desktop simulators for Android/iOS
  • Loading branch information
ksidirop-laerdal committed Jan 17, 2025
1 parent 2c84c3a commit d26d8b8
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>

<!-- these versions are getting replaced by the build script in one swift pass -->
<Version>1.0.1208.0</Version>
<FileVersion>1.0.1208.0</FileVersion>
<PackageVersion>1.0.1208.0</PackageVersion>
<AssemblyVersion>1.0.1208.0</AssemblyVersion>
<Version>1.0.1225.0</Version>

<FileVersion>$(Version)</FileVersion>
<PackageVersion>$(Version)</PackageVersion>
<AssemblyVersion>$(Version)</AssemblyVersion>

<Title>$(PackageId)</Title>
<Owners>$(Authors)</Owners>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,11 @@
<AllowedReferenceRelatedFileExtensions>$(AllowedReferenceRelatedFileExtensions);.pdb</AllowedReferenceRelatedFileExtensions>

<!-- these versions are getting replaced by the build script in one swift pass -->
<Version>1.0.1208.0</Version>
<FileVersion>1.0.1208.0</FileVersion>
<PackageVersion>1.0.1208.0</PackageVersion>
<AssemblyVersion>1.0.1208.0</AssemblyVersion>
<Version>1.0.1225.0</Version>

<FileVersion>$(Version)</FileVersion>
<PackageVersion>$(Version)</PackageVersion>
<AssemblyVersion>$(Version)</AssemblyVersion>

<Title>$(PackageId)</Title>
<Summary>McuMgr Bindings for MacCatalyst - MAUI ready</Summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@
<AllowedReferenceRelatedFileExtensions>$(AllowedReferenceRelatedFileExtensions);.pdb</AllowedReferenceRelatedFileExtensions>

<!-- these versions are getting replaced by the build script in one swift pass -->
<Version>1.0.1208.0</Version>
<FileVersion>1.0.1208.0</FileVersion>
<PackageVersion>1.0.1208.0</PackageVersion>
<AssemblyVersion>1.0.1208.0</AssemblyVersion>
<Version>1.0.1225.0</Version>

<FileVersion>$(Version)</FileVersion>
<PackageVersion>$(Version)</PackageVersion>
<AssemblyVersion>$(Version)</AssemblyVersion>

<Title>$(PackageId)</Title>
<Summary>McuMgr C# Implementation (WIP)</Summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@
<AllowedReferenceRelatedFileExtensions>$(AllowedReferenceRelatedFileExtensions);.pdb</AllowedReferenceRelatedFileExtensions>

<!-- these versions are getting replaced by the build script in one swift pass -->
<Version>1.0.1208.0</Version>
<FileVersion>1.0.1208.0</FileVersion>
<PackageVersion>1.0.1208.0</PackageVersion>
<AssemblyVersion>1.0.1208.0</AssemblyVersion>
<Version>1.0.1225.0</Version>

<FileVersion>$(Version)</FileVersion>
<PackageVersion>$(Version)</PackageVersion>
<AssemblyVersion>$(Version)</AssemblyVersion>

<Title>$(PackageId)</Title>
<Summary>McuMgr Bindings for iOS - MAUI ready</Summary>
Expand Down
6 changes: 4 additions & 2 deletions Laerdal.McuMgr.slnx.DotSettings.user
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AAndroidFirmwareInstaller_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003FDominic_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F70029469267e4beb864e0766d0bb075d17a00_003Fa8_003Ffbdeecdb_003FAndroidFirmwareInstaller_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AEIOSDeviceResetterState_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fb9912c9f4b224e928fbee944914df02d1b0c00_003F42_003F82a3227f_003FEIOSDeviceResetterState_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AExceptionAssertionsExtensions_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003FDominic_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fa6388411dabef15064d56ef6564bbd8ec27419b94df54d04263c246481d07_003FExceptionAssertionsExtensions_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATask_00601_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003FDominic_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F243a037ca7a04510a506adfdd94befbac90930_003F74_003F5841babc_003FTask_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CustomTools/CustomToolsData/@EntryValue"></s:String>
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=5074b48a_002Ddd85_002D447d_002Db5d1_002D16b7a75eed14/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;&#xD;
&lt;Solution /&gt;&#xD;
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=5074b48a_002Ddd85_002D447d_002Db5d1_002D16b7a75eed14/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;
&lt;Solution /&gt;
&lt;/SessionState&gt;</s:String>
<s:Boolean x:Key="/Default/UnloadedProject/UnloadedProjects/=131e5d65_002D002c_002D354a_002D58d9_002D743f2733d18b_0023Laerdal_002EMcuMgr_002EBindings_002EAndroid/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UnloadedProject/UnloadedProjects/=1eebca17_002Dfd57_002Db6cc_002Dece8_002D1a5895cd083f_0023Laerdal_002EMcuMgr_002EBindings_002EMacCatalyst/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UnloadedProject/UnloadedProjects/=7674d292_002D10b2_002Dc83c_002D9cd9_002D47a43552ee3a_0023Laerdal_002EMcuMgr_002ETests/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UnloadedProject/UnloadedProjects/=962e09e8_002D0e53_002D1451_002D63b3_002D13d08deac464_0023Laerdal_002EMcuMgr_002EBindings_002ENetStandard/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UnloadedProject/UnloadedProjects/=b3bb4f82_002D8427_002D49d7_002D5e69_002De0f8ffbb8be7_0023Laerdal_002EMcuMgr_002EBindings_002EiOS/@EntryIndexedValue">True</s:Boolean>

Expand Down
36 changes: 22 additions & 14 deletions Laerdal.McuMgr/Laerdal.McuMgr.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@
<IsHostMachineWindows Condition=" '$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true' ">true</IsHostMachineWindows>
<IsHostMachineUnix Condition=" '$(IsHostMachineOSX)' == 'true' OR '$(IsHostMachineLinux)' == 'true' ">true</IsHostMachineUnix>

<!-- - note that we build against netstandard2.1 merely as a dud-placeholder for windows in which we are bound to get not-implemented exceptions all over the place -->
<!-- - note that we build against net8.0 merely as a dud-placeholder for windows in which we are bound to get not-implemented exceptions all over the place -->
<!-- - the dud build for net8 also comes in handy when we want to launch an application inside an ios-simulator in the macos desktop (for UI testing purposes) -->
<!-- - also note it only makes sense to build ios stuff under osx because xcodebuild is only available there -->
<!-- - in azure we omit building maccatalyst for the time being because net8 needs maccatalyst 17.2+ which is only available on macos14 which microsoft currently (Q1 2024) doesn't provide us with in azure just yet -->

<PackageVersionPostfix Condition=" '$(BuildOnlyDudNet8)' == 'true' ">-force-dud</PackageVersionPostfix>

<TargetFrameworks>$(TargetFrameworks)net8.0;</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworks)net8.0-android;</TargetFrameworks>
<TargetFrameworks Condition=" '$(IsHostMachineOSX)' == 'true' ">$(TargetFrameworks)net8.0-ios11;</TargetFrameworks>
<TargetFrameworks Condition=" '$(IsHostMachineOSX)' == 'true' and '$(Should_Skip_MacCatalyst)' != 'true' ">$(TargetFrameworks)net8.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition=" '$(BuildOnlyDudNet8)' != 'true' ">$(TargetFrameworks)net8.0-android;</TargetFrameworks>
<TargetFrameworks Condition=" '$(BuildOnlyDudNet8)' != 'true' and '$(IsHostMachineOSX)' == 'true' ">$(TargetFrameworks)net8.0-ios;</TargetFrameworks>
<TargetFrameworks Condition=" '$(BuildOnlyDudNet8)' != 'true' and '$(IsHostMachineOSX)' == 'true' and '$(Should_Skip_MacCatalyst)' != 'true' ">$(TargetFrameworks)net8.0-maccatalyst</TargetFrameworks>

<IsDudNet8_0 Condition=" '$(TargetFramework)' == 'net8.0' ">true</IsDudNet8_0>
<IsDudNet8_0 Condition=" '$(TargetFramework)' == 'net8.0' ">true</IsDudNet8_0>
<IsNet8 Condition=" '$(TargetFramework.ToLower().StartsWith(net8))' == 'true' ">true</IsNet8>
<IsNet8IOS Condition=" '$(TargetFramework.ToLower().StartsWith(net8.0-ios))' == 'true' ">true</IsNet8IOS>
<IsNet8Android Condition=" '$(TargetFramework.ToLower().StartsWith(net8.0-android))' == 'true' ">true</IsNet8Android>
Expand Down Expand Up @@ -73,10 +76,14 @@
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>

<!-- these versions are getting replaced by the build script in one swift pass -->
<Version>1.0.1208.0</Version>
<FileVersion>1.0.1208.0</FileVersion>
<PackageVersion>1.0.1208.0</PackageVersion>
<AssemblyVersion>1.0.1208.0</AssemblyVersion>
<Version>1.0.1225.0</Version>

<FileVersion>$(Version)</FileVersion>
<PackageVersion>$(Version)</PackageVersion>
<AssemblyVersion>$(Version)</AssemblyVersion>

<!-- keep this because it is needed to generate the *-force-dud nuget packages! -->
<PackageVersion>$(PackageVersion)$(PackageVersionPostfix)</PackageVersion>

<Title>$(PackageId)</Title>
<Owners>$(Authors)</Owners>
Expand Down Expand Up @@ -169,21 +176,22 @@

<!-- ANDROID -->
<ItemGroup Condition=" '$(IsAndroid)' == 'true' ">
<PackageReference Include="Laerdal.McuMgr.Bindings.Android" Version="1.0.1208.0"/>
<PackageReference Include="Laerdal.McuMgr.Bindings.Android" Version="1.0.1225.0"/>
</ItemGroup>

<!-- IOS/MacCatalyst -->
<!-- IOS -->
<ItemGroup Condition=" '$(IsIOS)' == 'true' ">
<PackageReference Include="Laerdal.McuMgr.Bindings.iOS" Version="1.0.1208.0"/>
<PackageReference Include="Laerdal.McuMgr.Bindings.iOS" Version="1.0.1225.0"/>
</ItemGroup>

<!-- MACCATALYST -->
<ItemGroup Condition=" '$(IsNetXMacCatalyst)' == 'true' and '$(Should_Skip_MacCatalyst)' != 'true' ">
<PackageReference Include="Laerdal.McuMgr.Bindings.MacCatalyst" Version="1.0.1208.0"/>
<PackageReference Include="Laerdal.McuMgr.Bindings.MacCatalyst" Version="1.0.1225.0"/>
</ItemGroup>

<!-- NETSTANDARD -->
<ItemGroup Condition=" '$(IsDudNet8_0)' == 'true' ">
<PackageReference Include="Laerdal.McuMgr.Bindings.NetStandard" Version="1.0.1208.0"/>
<PackageReference Include="Laerdal.McuMgr.Bindings.NetStandard" Version="1.0.1225.0"/>
</ItemGroup>

</Project>
11 changes: 7 additions & 4 deletions Laerdal.Scripts/Laerdal.Builder.targets
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,6 @@

<Target Name="_updatePackageVersionsInCsprojFile">
<_replaceRegexInFile InputFile="$(ProjectFile)" Regex="&lt;Version&gt;.*?&lt;/Version&gt;" ReplacementText="&lt;Version&gt;$(Version)&lt;/Version&gt;"/>
<_replaceRegexInFile InputFile="$(ProjectFile)" Regex="&lt;FileVersion&gt;.*?&lt;/FileVersion&gt;" ReplacementText="&lt;FileVersion&gt;$(Version)&lt;/FileVersion&gt;"/>
<_replaceRegexInFile InputFile="$(ProjectFile)" Regex="&lt;PackageVersion&gt;.*?&lt;/PackageVersion&gt;" ReplacementText="&lt;PackageVersion&gt;$(Version)&lt;/PackageVersion&gt;"/>
<_replaceRegexInFile InputFile="$(ProjectFile)" Regex="&lt;AssemblyVersion&gt;.*?&lt;/AssemblyVersion&gt;" ReplacementText="&lt;AssemblyVersion&gt;$(Version)&lt;/AssemblyVersion&gt;"/>

<!-- this affects only laerdal.mcumgr.csproj -->
<_replaceRegexInFile InputFile="$(ProjectFile)"
Expand Down Expand Up @@ -254,7 +251,13 @@

<!-- notice that we are actually rebuilding mcumgr merely building the project doesnt really cut it -->
<MSBuild Projects="$(Laerdal_McuMgr_ProjectFile)"
Properties="$(_Laerdal_Build_Parameters);Laerdal_Bindings_Android___DotnetTargetPlatformVersion=$(Laerdal_Bindings_Android___DotnetTargetPlatformVersion);Laerdal_Bindings_iOS___DotnetTargetPlatformVersion=$(Laerdal_Bindings_iOS___DotnetTargetPlatformVersion);Laerdal_Bindings_MacCatalyst___DotnetTargetPlatformVersion=$(Laerdal_Bindings_MacCatalyst___DotnetTargetPlatformVersion);SourceRoot=$(Laerdal_RootDirectory_Folderpath)/Laerdal.McuMgr/;" Targets="Restore;Rebuild"/>
Properties="$(_Laerdal_Build_Parameters);Laerdal_Bindings_Android___DotnetTargetPlatformVersion=$(Laerdal_Bindings_Android___DotnetTargetPlatformVersion);Laerdal_Bindings_iOS___DotnetTargetPlatformVersion=$(Laerdal_Bindings_iOS___DotnetTargetPlatformVersion);Laerdal_Bindings_MacCatalyst___DotnetTargetPlatformVersion=$(Laerdal_Bindings_MacCatalyst___DotnetTargetPlatformVersion);SourceRoot=$(Laerdal_RootDirectory_Folderpath)/Laerdal.McuMgr/;"
Targets="Restore;Rebuild"/>

<!-- -force-dud build aiming just pure net8 without bindings this is meant for desktop simulators of android and ios for ui testing purposes of apps -->
<MSBuild Projects="$(Laerdal_McuMgr_ProjectFile)"
Properties="$(_Laerdal_Build_Parameters);BuildOnlyDudNet8=true;SourceRoot=$(Laerdal_RootDirectory_Folderpath)/Laerdal.McuMgr/;"
Targets="Restore;Rebuild"/>
</Target>

<!-- TESTS -->
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,15 @@ dotnet \
But the same family of events in Android is never triggered from the underlying McuMgr libs of Nordic (it's only triggered when we want to emit certain warnings ourselves) so logging
in Android is very limited.

- Trying to use the iOS/Android flavours of this library in desktop-simulator for iOS/Android will probably result in compilation errors. If you want to perform general purpose
UI-testing on your desktop using such simulators you need to tweak your nuget references to use the `-force-dud` nuget of `Laerdal.McuMgr` like so:

```xml
<PackageReference Include="Laerdal.McuMgr" Version="2.3.4-force-dud">
<NoWarn>$(NoWarn);NU1605</NoWarn>
</PackageReference>
```

## Contributing

We welcome contributions to this project in the form of bug reports, feature requests, and pull requests.
Expand Down

0 comments on commit d26d8b8

Please sign in to comment.