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

dotnet sln add: doesn't add MAUI project for Deploy #42108

Closed
lambdageek opened this issue Jul 11, 2024 · 3 comments
Closed

dotnet sln add: doesn't add MAUI project for Deploy #42108

lambdageek opened this issue Jul 11, 2024 · 3 comments
Assignees
Labels
Area-Workloads untriaged Request triage from a team member

Comments

@lambdageek
Copy link
Member

Describe the bug

If I create a new MAUI project using the CLI and then create a solution file and add the project to the solution, then the Visual Studio Configuration Manager shows that the solution is only configured for Build (in both Debug and Release configurations), but it is not selected for Deploy.

This is a problem because as a result hitting "Run with Debugging" in VS for an android target (and I assume for an ios target, too) will not actually deploy and debug the project. Instead the build window shows:

2>------ Skipped Deploy: Project: maui2, Configuration: Debug Any CPU ------
2>Project not selected to build for this solution configuration 

Manually right-clicking on the solution and checking the "Deploy" checkbox for the configuration(s) makes it work, but it is not obvious that is what is required.

Compare these two .sln files.

This is what you get from dotnet sln add:


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "maui2", "maui2.csproj", "{3BE1E2A0-90E0-4D42-92B2-D7CDDA300CEE}"
EndProject
Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Any CPU = Debug|Any CPU
                Release|Any CPU = Release|Any CPU
        EndGlobalSection
        GlobalSection(ProjectConfigurationPlatforms) = postSolution
                {3BE1E2A0-90E0-4D42-92B2-D7CDDA300CEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
                {3BE1E2A0-90E0-4D42-92B2-D7CDDA300CEE}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {3BE1E2A0-90E0-4D42-92B2-D7CDDA300CEE}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {3BE1E2A0-90E0-4D42-92B2-D7CDDA300CEE}.Release|Any CPU.Build.0 = Release|Any CPU
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE
        EndGlobalSection
EndGlobal

And this is what you get if you click the 'Deploy' checkboxes:

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "maui2", "maui2.csproj", "{3BE1E2A0-90E0-4D42-92B2-D7CDDA300CEE}"
EndProject
Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Any CPU = Debug|Any CPU
                Release|Any CPU = Release|Any CPU
        EndGlobalSection
        GlobalSection(ProjectConfigurationPlatforms) = postSolution
                {3BE1E2A0-90E0-4D42-92B2-D7CDDA300CEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
                {3BE1E2A0-90E0-4D42-92B2-D7CDDA300CEE}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {3BE1E2A0-90E0-4D42-92B2-D7CDDA300CEE}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
                {3BE1E2A0-90E0-4D42-92B2-D7CDDA300CEE}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {3BE1E2A0-90E0-4D42-92B2-D7CDDA300CEE}.Release|Any CPU.Build.0 = Release|Any CPU
                {3BE1E2A0-90E0-4D42-92B2-D7CDDA300CEE}.Release|Any CPU.Deploy.0 = Release|Any CPU
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE
        EndGlobalSection
EndGlobal

To Reproduce

  1. Install .NET 8.0 SDK or a .NET 9 Preview SDK
  2. Install the MAUI workload
  3. mkdir maui2 and cd maui2
  4. dotnet new maui -f net8.0
  5. dotnet new sln
  6. dotnet sln maui2.sln add .\maui2.csproj
  7. open the resulting project in Visual Studio 2022 (I have 17.11 Preview 3, but probably 17.10 has the same behavior)
  8. select an appropriate x86-64 android emultator
  9. hit F5 or click "Run with Debugging"
  10. Observe the error from above
  11. Right click on the solution and click "Configuration Manager" and check the "Deploy" checkboxes
  12. hit F5
  13. App is running in the android emulator

Exceptions (if any)

Further technical details

PS E:\maui2> dotnet --info
.NET SDK:
 Version:           9.0.100-preview.6.24328.19
 Commit:            ef4c241666
 Workload version:  9.0.100-manifests.7e18eb25
 MSBuild version:   17.11.0-preview-24318-05+4a45d5633

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22631
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.100-preview.6.24328.19\

.NET workloads installed:
Configured to use loose manifests when installing new manifests.
 [android]
   Installation Source: SDK 9.0.100-preview.6, VS 17.11.35103.136
   Manifest Version:    34.99.0-preview.6.340/9.0.100-preview.6
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100-preview.6\microsoft.net.sdk.android\34.99.0-preview.6.340\WorkloadManifest.json
   Install Type:              Msi

 [ios]
   Installation Source: SDK 9.0.100-preview.6, VS 17.11.35103.136
   Manifest Version:    17.2.9714-net9-p6/9.0.100-preview.6
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100-preview.6\microsoft.net.sdk.ios\17.2.9714-net9-p6\WorkloadManifest.json
   Install Type:              Msi

 [maccatalyst]
   Installation Source: SDK 9.0.100-preview.6, VS 17.11.35103.136
   Manifest Version:    17.2.9714-net9-p6/9.0.100-preview.6
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100-preview.6\microsoft.net.sdk.maccatalyst\17.2.9714-net9-p6\WorkloadManifest.json
   Install Type:              Msi

 [maui]
   Installation Source: SDK 9.0.100-preview.6
   Manifest Version:    9.0.0-preview.6.24327.7/9.0.100-preview.6
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100-preview.6\microsoft.net.sdk.maui\9.0.0-preview.6.24327.7\WorkloadManifest.json
   Install Type:              Msi

 [maui-windows]
   Installation Source: SDK 9.0.100-preview.6, VS 17.11.35103.136
   Manifest Version:    9.0.0-preview.6.24327.7/9.0.100-preview.6
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100-preview.6\microsoft.net.sdk.maui\9.0.0-preview.6.24327.7\WorkloadManifest.json
   Install Type:              Msi

 [wasm-tools]
   Installation Source: SDK 9.0.100-preview.6, VS 17.11.35103.136
   Manifest Version:    9.0.0-preview.6.24327.7/9.0.100-preview.6
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100-preview.6\microsoft.net.workload.mono.toolchain.current\9.0.0-preview.6.24327.7\WorkloadManifest.json
   Install Type:              Msi

 [wasm-tools-net7]
   Installation Source: SDK 9.0.100-preview.6, VS 17.11.35103.136
   Manifest Version:    9.0.0-preview.6.24327.7/9.0.100-preview.6
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\9.0.100-preview.6\microsoft.net.workload.mono.toolchain.net7\9.0.0-preview.6.24327.7\WorkloadManifest.json
   Install Type:              Msi


Host:
  Version:      9.0.0-preview.6.24327.7
  Architecture: x64
  Commit:       static

.NET SDKs installed:
  8.0.107 [C:\Program Files\dotnet\sdk]
  8.0.303 [C:\Program Files\dotnet\sdk]
  8.0.400-preview.0.24324.5 [C:\Program Files\dotnet\sdk]
  9.0.100-preview.6.24328.19 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.0-preview.6.24328.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.0-preview.6.24327.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.19 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.0-preview.6.24327.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  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

Visual Studio:

Microsoft Visual Studio Enterprise 2022
Version 17.11.0 Preview 3.0
VisualStudio.17.Preview/17.11.0-pre.3.0+35103.136
Microsoft .NET Framework
Version 4.8.09032

Installed Version: Enterprise

Visual C++ 2022   
Microsoft Visual C++ 2022

ASP.NET and Web Tools   17.11.227.26177
ASP.NET and Web Tools

Azure App Service Tools v3.0.0   17.11.227.26177
Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools   17.11.227.26177
Azure Functions and Web Jobs Tools

C# Tools   4.11.0-3.24329.1+92051d4c24bc13ff58232104a647910bf22cd105
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Extensibility Message Bus   1.4.39 (main@e8108eb)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

GitHub Copilot   0.2.1586.52275
GitHub Copilot is an AI pair programmer that helps you write code faster and with less work.

Microsoft Azure Tools for Visual Studio   2.9
Support for Azure Cloud Services projects

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Mono Debugging for Visual Studio   17.11.3 (ba13144)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   6.11.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Razor (ASP.NET Core)   17.11.3.2432707+ea83da42ade2a5e193507d780559d79f0cb16c75
Provides languages services for ASP.NET Core Razor.

SQL Server Data Tools   17.11.38.0
Microsoft SQL Server Data Tools

Test Adapter for Boost.Test   1.0
Enables Visual Studio's testing tools with unit tests written for Boost.Test.  The use terms and Third Party Notices are available in the extension installation directory.

Test Adapter for Google Test   1.0
Enables Visual Studio's testing tools with unit tests written for Google Test.  The use terms and Third Party Notices are available in the extension installation directory.

TypeScript Tools   17.0.30625.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   4.11.0-3.24329.1+92051d4c24bc13ff58232104a647910bf22cd105
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools   17.11.0-beta.24317.3+c07c8ebad62f6629b36349381991a299598a8d74
Microsoft Visual F# Tools

Visual Studio IntelliCode   2.2
AI-assisted development for Visual Studio.

VisualStudio.DeviceLog   1.0
Information about my package

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

VSPackage Extension   1.0
VSPackage Visual Studio Extension Detailed Info

Xamarin   17.11.0.86 (main@9d38808)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer   17.11.3.10 (remotes/origin/d17-11@714146c62b)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin.Android SDK   13.2.2.0 (d17-5/45b0e14)
Xamarin.Android Reference Assemblies and MSBuild support.
    Mono: d9a6e87
    Java.Interop: xamarin/java.interop/d17-5@149d70fe
    SQLite: xamarin/sqlite/3.40.1@68c69d8
    Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-5@ca1552d
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Workloads untriaged Request triage from a team member labels Jul 11, 2024
@lambdageek
Copy link
Member Author

possibly related #10359

@lambdageek
Copy link
Member Author

lambdageek commented Jul 11, 2024

Checking if this affects the .NET MAUI extension in VS Code. They don't have a Configuration Manager UI and I think VS Code users are much more likely to use the CLI

Nope .NET MAUI extension in VS Code doesn't seem to care about "Deploy". So it's just VS 2022 that's affected

@MiYanni
Copy link
Member

MiYanni commented Feb 15, 2025

To preface, I don't really know anything about MAUI, but from my understanding of this issue, there doesn't seem to be a problem here (meaning that both tools, dotnet CLI and VS, are working as intended).

  • dotnet sln add will only ever add the project with the default Debug and Release configurations. There's not a mechanism for it to be aware of other configurations.
  • Visual Studio has a vastly different understanding of the "state of a solution", so it might have some kind of logic for MAUI projects to be aware that a Deploy configuration would exist. There's nothing of that sort of contextual awareness in the dotnet CLI. As you mentioned, you needed to add the at configuration to the project using the VS Configuration Manager, which is the intended use-case for that dialog.

If you still think there is an issue, I'd recommend filing something over in https://github.com/dotnet/maui and mention this issue there so they can have some context/understanding.

@MiYanni MiYanni closed this as not planned Won't fix, can't repro, duplicate, stale Feb 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Workloads untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

2 participants