Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] .NET MAUI extension does not respect target device if configuration is different than Debug #732

Closed
luwed opened this issue Nov 17, 2023 · 4 comments
Assignees
Labels
area-maui area-project-cps bug Something isn't working fixed mac MacOS triaged The issue has been triaged vs-sync Add this label to synchronize the issue to AzDo vs-syncd Linked to AzDO
Milestone

Comments

@luwed
Copy link

luwed commented Nov 17, 2023

Describe the Issue

I noticed that app is not deployed to device/emulator if custom launch configuration is selected and more that one emulator/device is running. There is error in terminal:

[...]
[73/73] System.Private.CoreLib.dll -> System.Private.CoreLib.dll.so
  [73/73] System.Private.CoreLib.dll -> System.Private.CoreLib.dll.so
  [73/73] System.Private.CoreLib.dll -> System.Private.CoreLib.dll.so
[BT : 1.8.1] error : More than one device connected, please provide --device-id. [/Users/<username>/Projects/TestMaui/TestMaui.csproj::TargetFramework=net7.0-android]

Build FAILED.

[BT : 1.8.1] error : More than one device connected, please provide --device-id. [/Users/<username>/Projects/TestMaui/TestMaui.csproj::TargetFramework=net7.0-android]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:03:00.18

 *  The terminal process "/bin/bash '-l', '-c', 'dotnet build -t:Run -p:Configuration=Release -f net7.0-android -p:AndroidSdkDirectory='/private/var/<username>/Library/Android/sdk' -p:JavaSdkDirectory='/Library/Java/JavaVirtualMachines/microsoft-11.jdk/Contents/Home' /Users/<username>/Projects/TestMaui/TestMaui.csproj'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 
  • The issue is similar to [BUG] .NET MAUI extension always starts with the device target first available on the list no matter what the user selection is #250.
  • For Debug configuration following command is run in terminal:
    * Executing task: dotnet build -t:Run -p:Configuration=Debug -f net7.0-android -p:AdbTarget=-s%20__SERIAL__ -p:AndroidAttachDebugger=true -p:AndroidSdbTargetPort=52096 -p:AndroidSdbHostPort=52096 -p:AndroidSdkDirectory='/private/var/<username>/Library/Android/sdk' -p:JavaSdkDirectory='/Library/Java/JavaVirtualMachines/microsoft-11.jdk/Contents/Home' /Users/<username>/Projects/TestMaui/TestMaui.csproj
  • For Release configuration following command is run in terminal:
    * Executing task: dotnet build -t:Run -p:Configuration=Release -f net7.0-android -p:AndroidSdkDirectory='/private/var/<username>/Library/Android/sdk' -p:JavaSdkDirectory='/Library/Java/JavaVirtualMachines/microsoft-11.jdk/Contents/Home' /Users/<username>/Projects/TestMaui/TestMaui.csproj

Steps To Reproduce

Prerequisites

  • Launch two emulators
  1. Create folder TestMaui
  2. Open folder in Terminal
  3. Create new .NET MAUI project running command: 'dotnet new maui'
  4. Open project in Visual Studio Code. Below you can see csproj:
<Project Sdk="Microsoft.NET.Sdk">

	<PropertyGroup>
		<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
		<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.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> -->
		<OutputType>Exe</OutputType>
		<RootNamespace>TestMaui</RootNamespace>
		<UseMaui>true</UseMaui>
		<SingleProject>true</SingleProject>
		<ImplicitUsings>enable</ImplicitUsings>

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

		<!-- App Identifier -->
		<ApplicationId>com.companyname.testmaui</ApplicationId>
		<ApplicationIdGuid>15294e6f-04e4-41d7-aa21-522ed35a564b</ApplicationIdGuid>

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

		<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>
		<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
	</PropertyGroup>

	<ItemGroup>
		<!-- App Icon -->
		<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />

		<!-- Splash Screen -->
		<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />

		<!-- Images -->
		<MauiImage Include="Resources\Images\*" />
		<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />

		<!-- Custom Fonts -->
		<MauiFont Include="Resources\Fonts\*" />

		<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
		<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
	</ItemGroup>

	<ItemGroup>
		<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
	</ItemGroup>

</Project>
  1. Create launch.json:
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "[Debug] Test Maui",
            "type": "maui",
            "request": "launch",
            "preLaunchTask": "maui: Build"
        },
        {
            "name": "[Release] Test Maui",
            "type": "maui",
            "request": "launch",
            "configuration": "Release",
            "preLaunchTask": "maui: Build"
        }        
    ]
}
  1. Select target device
  2. Open Debug view
  3. Select '[Release] Test Maui' from Dropdown

Expected Behavior

App is deployed to proper device/emulator.

Environment Information

  • OS: macOS Ventura 13.5.1
  • VS Code version: 1.84.2
  • Extensions: .NET MAUI v0.6.19, C# Dev Kit v1.0.14, C# v2.10.28

VS bug #1921025

@luwed luwed added the bug Something isn't working label Nov 17, 2023
@mauroa mauroa self-assigned this Nov 22, 2023
@mauroa mauroa added vs-sync Add this label to synchronize the issue to AzDo triaged The issue has been triaged labels Nov 22, 2023
@mauroa
Copy link
Member

mauroa commented Nov 22, 2023

Hi @luwed, this issue is currently being investigated. Our team will get back to you if either more information is needed, a workaround is available, or the issue is resolved.

@luwed
Copy link
Author

luwed commented Nov 23, 2023

Hi @mauroa, thanks.

@AllenD-MSFT AllenD-MSFT added the vs-syncd Linked to AzDO label Dec 15, 2023
@mauroa
Copy link
Member

mauroa commented Mar 19, 2024

There's a fix available for this issue that will be published in the next VS Code MAUI pre-release version. We'll proceed to close this issue once that version is available to install.

Copy link

github-actions bot commented Apr 3, 2024

This issue has been marked as stale after 14 days of inactivity. @[ @mauroa @], could you please take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-maui area-project-cps bug Something isn't working fixed mac MacOS triaged The issue has been triaged vs-sync Add this label to synchronize the issue to AzDo vs-syncd Linked to AzDO
Projects
None yet
Development

No branches or pull requests

4 participants