microsoftconnect / ms-intune-app-sdk-android

Intune App SDK for Android enables data protection features and mobile app management via Microsoft Intune
45 stars 18 forks source link

[.NET MAUI] Microsoft.Intune.Maui.Essentials.Android Tries to run targets on non-android TargetFrameworks #176

Closed MikeP0911 closed 1 year ago

MikeP0911 commented 1 year ago

Intune Android App SDK for .NET MAUI Issue

Summary

Created a new MAUI project and installed the Microsoft.Intune.Maui.Essentials.android version 9.5.2 Beta. Immediately it throws

Intune integration requires .Net 7.0. Please upgrade your app's target framework version. MyMaui C:\NugetPackages\microsoft.intune.maui.essentials.android\9.5.2-beta2\build\netstandard2.0\Microsoft.Intune.Maui.Essentials.android.targets

Details

Logs

1>C:\NugetPackages\microsoft.intune.maui.essentials.android\9.5.2-beta2\build\netstandard2.0\Microsoft.Intune.Maui.Essentials.android.targets(131,9): error : Intune integration requires .Net 7.0. Please upgrade your app's target framework version. 1>Done building project "MyMaui.csproj" -- FAILED.

  1. Does the app build and launch without including the Microsoft.Intune.Maui.Essentials.android package? Yes
  2. Does the issue reproduce if you rebuild after deleting the bin and obj output folders?Yes
  3. Have you checked the .NET MAUI repository for similar issues? If so, please follow the guidance there or add that information to this issue. Not Available
  4. Are you using the latest Microsoft.Intune.Maui.Essentials.android NuGet package version? Yes
MikeP0911 commented 1 year ago

To Reproduce Steps to reproduce the behavior:

  1. Using visual studio for windows17.7.2
  2. Create a new .NET MAUI App or an Android Application
  3. Add Microsoft.Intune.Maui.Essentials.Android nuget package
  4. Try to build the project
  5. The build fails with the following message

1>C:\NugetPackages\microsoft.intune.maui.essentials.android\9.5.2-beta2\build\netstandard2.0\Microsoft.Intune.Maui.Essentials.android.targets(131,9): error : Intune integration requires .Net 7.0. Please upgrade your app's target framework version. 1>Done building project "MyMaui.csproj" -- FAILED.

Archit-Pikle commented 1 year ago

Hi @MikeP0911, Microsoft.Intune.Maui.Essentials.android requires the MAUI app to have a target framework of .NET 7.0. Can you please confirm your MAUI app is targetting .NET 7?

MikeP0911 commented 1 year ago
net7.0-ios;net7.0-maccatalyst;net7.0-android33.0 $(TargetFrameworks);net7.0-windows10.0.19041.0 Exe MyMaui true true enable MyMaui com.companyname.mymaui 91e8efcb-5f3a-4b44-a3be-d01168db3acd 1.0 1 11.0 13.1 29.0 10.0.17763.0 10.0.17763.0 6.5
MikeP0911 commented 1 year ago

@Archit-Pikle This is my csproj. Im not sure where im missing Below is the info.

.NET SDK: Version: 7.0.400 Commit: 73bf45718d

Runtime Environment: OS Name: Windows OS Version: 10.0.22621 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\7.0.400\

Host: Version: 7.0.10 Architecture: x64 Commit: a6dbb800a4

.NET SDKs installed: 3.1.426 [C:\Program Files\dotnet\sdk] 5.0.101 [C:\Program Files\dotnet\sdk] 5.0.104 [C:\Program Files\dotnet\sdk] 5.0.408 [C:\Program Files\dotnet\sdk] 5.0.416 [C:\Program Files\dotnet\sdk] 6.0.310 [C:\Program Files\dotnet\sdk] 7.0.400 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found: arm64 [C:\Program Files\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\arm64\InstallLocation] x86 [C:\Program Files (x86)\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables: Not set

global.json file: Not found

Learn more: https://aka.ms/dotnet/info

Download .NET: https://aka.ms/dotnet/download

MikeP0911 commented 1 year ago

This is same like the problem mentioned below

https://github.com/msintuneappsdk/ms-intune-app-sdk-android/issues/174

Archit-Pikle commented 1 year ago

Does it build if you replace “net7.0-android33.0” with “net7.0-android” in the target frameworks?

MikeP0911 commented 1 year ago

@Archit-Pikle

We have changed as per your advice. Still the problem exists. Please suggest.

Error:

Build started... 1>------ Build started: Project: MyMauiApp, Configuration: Debug Any CPU ------ Restored C:\Maui\MyMauiApp\MyMauiApp\MyMauiApp.csproj (in 400 ms). 1>C:\NugetPackages\microsoft.intune.maui.essentials.android\9.5.2-beta2\build\netstandard2.0\Microsoft.Intune.Maui.Essentials.android.targets(131,9): error : Intune integration requires .Net 7.0. Please upgrade your app's target framework version. 1>Done building project "MyMauiApp.csproj" -- FAILED. 1>C:\NugetPackages\microsoft.intune.maui.essentials.android\9.5.2-beta2\build\netstandard2.0\Microsoft.Intune.Maui.Essentials.android.targets(131,9): error : Intune integration requires .Net 7.0. Please upgrade your app's target framework version. 1>Done building project "MyMauiApp.csproj" -- FAILED. 1>C:\NugetPackages\microsoft.intune.maui.essentials.android\9.5.2-beta2\build\netstandard2.0\Microsoft.Intune.Maui.Essentials.android.targets(131,9): error : Intune integration requires .Net 7.0. Please upgrade your app's target framework version. 1>Done building project "MyMauiApp.csproj" -- FAILED. 1>MyMauiApp -> C:\Maui\MyMauiApp\MyMauiApp\bin\Debug\net7.0-android\MyMauiApp.dll 1>Zipping directory "C:\Maui\MyMauiApp\MyMauiApp\obj\Debug\net7.0-android\intune\android\bin\classes\" to "C:\Maui\MyMauiApp\MyMauiApp\obj\Debug\net7.0-android\intune\android\bin\classes.zip". ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== ========== Build started at 10:43 AM and took 01:14.540 minutes ==========

net7.0-android;net7.0-ios;net7.0-maccatalyst $(TargetFrameworks);net7.0-windows10.0.19041.0 Exe MyMauiApp true true enable MyMauiApp com.companyname.mymauiapp 01211571-2772-48c8-bce0-9c15e333a294 1.0 1 11.0 13.1 21.0 10.0.17763.0 10.0.17763.0 6.5
MikeP0911 commented 1 year ago

@Archit-Pikle Were you able to reproduce this issue in your side?

Archit-Pikle commented 1 year ago

Hi @MikeP0911 , I was able to reproduce the issue. We'll be working on a fix and ship it in a future release.

In the meanwhile, can you instead add the following code and let me know if that resolves your issue? This code should import the Microsoft.Intune.Maui.Essentials.android package only for Android builds.

`

`

MikeP0911 commented 1 year ago

@Archit-Pikle I was able to successfully build if I could target for Android builds. Is there a way to download nuget packages only for the particular platform. If we install a nuget package from Nuget package manager it gets installed in all the platforms. Thank you.

MikeP0911 commented 1 year ago

@Archit-Pikle Im getting an error in MAM transformation of files. Please have a look. https://github.com/msintuneappsdk/ms-intune-app-sdk-android/issues/182

I this related due to the workaround.

Thanks

Archit-Pikle commented 1 year ago

The fix should be available in our latest release 10.0.0-beta2.

With this release, you no longer need to specify the TargetPlatformIdentifier while importing Microsoft.Intune.MAUI.Essentials.android