banditoth / MAUI.Packages

A toolkit for .NET MAUI 🏝, containing useful stuff to ease development for MAUI applications.
MIT License
39 stars 3 forks source link

'MauiAppBuilder' does not contain a definition for 'ConfigureJailbreakProtection' #6

Closed mirceamuresanse closed 1 year ago

mirceamuresanse commented 1 year ago

I created a new Maui app using VS 2022 and .NET 7. I added the NuGet package 'banditoth.MAUI.JailbreakDetector' and followed the steps from the readme.txt file. When building the app I get 2 errors:

Error 1: The type or namespace name 'banditoth' could not be found (are you missing a using directive or an assembly reference?)

Error 2: 'MauiAppBuilder' does not contain a definition for 'ConfigureJailbreakProtection' and no accessible extension method 'ConfigureJailbreakProtection' accepting a first argument of type 'MauiAppBuilder' could be found (are you missing a using directive or an assembly reference?)

I check in the project file and discovered that adding the NuGet package creates these 2 groups:

<ItemGroup Condition="'$(TargetFramework)' == 'net7.0-android'">
  <PackageReference Include="banditoth.MAUI.JailbreakDetector">
    <Version>1.0.0</Version>
  </PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net7.0-ios'">
  <PackageReference Include="banditoth.MAUI.JailbreakDetector">
    <Version>1.0.0</Version>
  </PackageReference>
</ItemGroup>

Nothing added for Windows. I tried adding one of these for Windows, but then I get a bunch of building errors stating that Windows is not supported.

At this point I'm stuck. Apparently this package can't be used, no matter if I select Windows, Android or iOS.

ueb375 commented 1 year ago

You can easily circumvent this problem by wrapping the using and .ConfigureJailbreakDetection block into #if !WINDOWS #endif preprocessor blocks.

banditoth commented 1 year ago

You can easily circumvent this problem by wrapping the using and .ConfigureJailbreakDetection block into #if !WINDOWS #endif preprocessor blocks.

Thanks for the answer on this problem. This is the solution.