dotnet / dotnet/maui

SDK Target Platforms .targets/.props files not loading on MAUI Project

Open
#5,847 15 comments 0 reactions 1 assignee Assigned to @jonathanpeppers View on GitHub
area-single-project partner/ui-tools partner/winui platform/windows s/move-to-vs-feedback s/triaged s/verified t/bug
Dominant language
C#
Stars
23.3k
Forks
2k
Avg merge
1d 15h
Merged PRs (30d)
290

Description

### Description
The following .props/.targets files don't always load on a MAUI project.
- Microsoft.Android.Sdk.SupportedPlatforms.targets
- Microsoft.iOS.Sdk.SupportedTargetPlatforms.props
- Microsoft.MacCatalyst.Sdk.SupportedTargetPlatforms.props

This happens even when the `TargetFrameworks` property contains all the target platforms (net6.0-ios, net6.0-android, and net6.0-maccatalyst). In fact, it only loads the file associated with the platform that is the first one in the list of values for the `TargetFrameworks` property. The windows file seems to always be loaded regardless of whether or not net6.0-windows is a target platform.

### Request
Can we always load those files regardless of whether or not the related platform is a target listed in the `TargetFrameworks` property?

This is necessary because we use those files to read the versions supported to display them to the user for them to select in a combo box (see picture below). So, we always need to display those values even when the framework is not selected, therefore those files should always be loaded.

![image](https://user-images.githubusercontent.com/77985069/161838650-095cd367-7ffe-496c-8ff4-a4b7e9f6fcd7.png)

### Steps to Reproduce

1. Create a MAUI project
2. Make sure net6.0-android, net6.0-ios and net6.0-maccatalyst is listed in the `TagetFrameworks` property.
3. Click the "Show all files" icon in the Solution Explorer
4. Search for "supported"
5. Note that only the `Microsoft.NET.WindowsSdkSupportedTargetPlatforms.props ` and the file related to the first platform listed in the `TargetFrameworks` is loaded.
6. Switch the order of the target platforms in the `TargetFrameworks` property.
7. Unload and reload the project
8. Repeat steps 3-5

See picture below for an example:
![image](https://user-images.githubusercontent.com/77985069/161839671-bfb122e7-dc38-450e-b59f-88309586ad88.png)

### Version with bug

Preview 14 (current)

### Last version that worked well

Preview 14 (current)

### Affected platforms

iOS, Android, macOS

### Affected platform versions

n/a

### Did you find any workaround?

_No response_

### Relevant log output

_No response_

> VS bug [#1744763](https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1744763)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.