Skip to content

Commit

Permalink
Merge pull request unoplatform#18517 from unoplatform/dev/jela/reorde…
Browse files Browse the repository at this point in the history
…r-17-12

fix: Adjust tf reordering for VS 17.12 or later
  • Loading branch information
jeromelaban authored Oct 19, 2024
2 parents 507b19f + a005e8b commit dad1f30
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 8 deletions.
12 changes: 12 additions & 0 deletions doc/articles/uno-build-error-codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,18 @@ When building with Rider on Linux or macOS, unsupported target frameworks are [n

See how to [make platforms conditional](xref:Uno.GettingStarted.CreateAnApp.Rider#considerations-for-macos-and-linux) for Rider.

### UNOB0015: The desktop TargetFramework must be placed first

In Visual Studio 17.12 or later, when both mobile (`-ios`, `-android`, `-maccatalyst`) and `desktop` target frameworks are used, the `-desktop` target framework must be placed first in order for WSL debugging to work.

If `-desktop` is not first, the following message will appear:

```text
The project doesn't know how to run the profile with name 'MyApp (Desktop WSL2)' and command 'WSL2'.
```

To fix the issue, reorder the items in your `.csproj` so that `TargetFrameworks` contains `netX.0-desktop` as the first target framework.

## Compiler Errors

### UNO0001
Expand Down
52 changes: 44 additions & 8 deletions src/Uno.Sdk/targets/Uno.Sdk.After.targets
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,23 @@
<When Condition="
'$(BuildingInsideVisualStudio)' == 'true'
AND '$(UnoDisableFirstTargetFrameworkRewrite)' != 'true'
AND (
$([MSBuild]::GetTargetPlatformIdentifier($(_UnoSelectedTargetFramework))) == 'browserwasm'
OR $([MSBuild]::GetTargetPlatformIdentifier($(_UnoSelectedTargetFramework))) == 'desktop'
OR $([MSBuild]::GetTargetPlatformIdentifier($(_UnoSelectedTargetFramework))) == 'windows'
AND
(
(
$([MSBuild]::VersionLessThan($(MSBuildVersion), 17.12.0))
AND (
$([MSBuild]::GetTargetPlatformIdentifier($(_UnoSelectedTargetFramework))) == 'browserwasm'
OR $([MSBuild]::GetTargetPlatformIdentifier($(_UnoSelectedTargetFramework))) == 'desktop'
OR $([MSBuild]::GetTargetPlatformIdentifier($(_UnoSelectedTargetFramework))) == 'windows'
)
)
OR
(
$([MSBuild]::VersionGreaterThanOrEquals($(MSBuildVersion), 17.12.0))
AND (
$([MSBuild]::GetTargetPlatformIdentifier($(_UnoSelectedTargetFramework))) == 'browserwasm'
)
)
)
AND '$(TargetFrameworks)' != ''
AND '$(_UnoFirstOriginalTargetFramework)' != '$(_UnoSelectedTargetFramework)'
Expand Down Expand Up @@ -76,23 +89,25 @@
</Choose>

<Target Name="_UnoVSWarnBrowserIsFirst"
BeforeTargets="_SetBuildInnerTarget;_ComputeTargetFrameworkItems"
BeforeTargets="_SetBuildInnerTarget;_ComputeTargetFrameworkItems;ResolveFrameworkReferences"
Condition="
'$(UnoDisableVSWarnBrowserIsFirst)' != 'true'
AND '$(BuildingInsideVisualStudio)' == 'true'
AND '$(_UnoTargetFrameworkCount)' != ''
AND $(_UnoTargetFrameworkCount) &gt; 1
AND $(TargetFrameworks.Contains('-browserwasm'))
AND $([MSBuild]::GetTargetPlatformIdentifier($(_UnoFirstOriginalTargetFramework))) == 'browserwasm'">

<Warning Code="UNOB0010"
Text="The browserwasm TargetFramework must not be placed first in the TargetFrameworks property in order for HotReload to work properly. (See https://aka.platform.uno/UNOB0010)" />
</Target>

<Target Name="_UnoVSWarnDesktopIsFirst"
BeforeTargets="_SetBuildInnerTarget;_ComputeTargetFrameworkItems"
BeforeTargets="_SetBuildInnerTarget;_ComputeTargetFrameworkItems;ResolveFrameworkReferences"
Condition="
'$(UnoDisableVSWarnDesktopIsFirst)' != 'true'
AND '$(BuildingInsideVisualStudio)' == 'true'
AND $([MSBuild]::VersionLessThan($(MSBuildVersion), 17.12.0))
AND '$(_UnoTargetFrameworkCount)' != ''
AND $(_UnoTargetFrameworkCount) &gt; 1
AND $([MSBuild]::GetTargetPlatformIdentifier($(_UnoFirstOriginalTargetFramework))) == 'desktop'">
Expand All @@ -101,21 +116,42 @@
Text="The desktop TargetFramework must not be placed first in the TargetFrameworks property in order for other platforms debugging to work. (See https://aka.platform.uno/UNOB0011)" />
</Target>

<Target Name="_UnoVSWarnDesktopIsNotFirst"
BeforeTargets="_SetBuildInnerTarget;_ComputeTargetFrameworkItems;ResolveFrameworkReferences"
Condition="
'$(UnoDisableVSWarnDesktopIsNotFirst)' != 'true'
AND '$(BuildingInsideVisualStudio)' == 'true'
AND $([MSBuild]::VersionGreaterThanOrEquals($(MSBuildVersion), 17.12.0))
AND '$(_UnoTargetFrameworkCount)' != ''
AND $(_UnoTargetFrameworkCount) &gt; 1
AND $(TargetFrameworks.Contains('-desktop'))
AND (
$(TargetFrameworks.Contains('-ios'))
OR $(TargetFrameworks.Contains('-android'))
OR $(TargetFrameworks.Contains('-maccatalyst'))
)
AND $([MSBuild]::GetTargetPlatformIdentifier($(_UnoFirstOriginalTargetFramework))) != 'desktop'">

<Warning Code="UNOB0014"
Text="The desktop TargetFramework must be placed first in the TargetFrameworks property in order for WSL debugging to work, when mobile targets are also used. (See https://aka.platform.uno/UNOB0014)" />
</Target>

<Target Name="_UnoVSWarnWindowsIsFirst"
BeforeTargets="_SetBuildInnerTarget;_ComputeTargetFrameworkItems"
BeforeTargets="_SetBuildInnerTarget;_ComputeTargetFrameworkItems;ResolveFrameworkReferences"
Condition="
'$(UnoDisableVSWarnWindowsIsFirst)' != 'true'
AND '$(BuildingInsideVisualStudio)' == 'true'
AND '$(_UnoTargetFrameworkCount)' != ''
AND $(_UnoTargetFrameworkCount) &gt; 1
AND $(TargetFrameworks.Contains('-windows'))
AND $([MSBuild]::GetTargetPlatformIdentifier($(_UnoFirstOriginalTargetFramework))) == 'windows'">

<Warning Code="UNOB0012"
Text="The windows TargetFramework must not be placed first in the TargetFrameworks property in order for other platforms debugging to work. (See https://aka.platform.uno/UNOB0012)" />
</Target>

<Target Name="_UnoVSWarnNetIsFirst"
BeforeTargets="_SetBuildInnerTarget;_ComputeTargetFrameworkItems"
BeforeTargets="_SetBuildInnerTarget;_ComputeTargetFrameworkItems;ResolveFrameworkReferences"
Condition="
'$(UnoDisableVSWarnNetIsFirst)' != 'true'
AND '$(BuildingInsideVisualStudio)' == 'true'
Expand Down

0 comments on commit dad1f30

Please sign in to comment.