Skip to content

Commit

Permalink
Merge pull request #19373 from unoplatform/dev/jela/wsl-vs
Browse files Browse the repository at this point in the history
fix: Use newer project capability for WSL in VS 17.13
  • Loading branch information
jeromelaban authored Jan 30, 2025
2 parents 2291f12 + e6dfb67 commit e3f600f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions doc/articles/uno-build-error-codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,15 @@ See how to [make platforms conditional](xref:Uno.GettingStarted.CreateAnApp.Ride

### 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.
In Visual Studio 17.13 or earlier, 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.
To fix the issue, reorder the items in your `.csproj` so that `TargetFrameworks` contains `netX.0-desktop` as the first target framework, or upgrade to Visual Studio 17.13 (when a stable release will be available).

The Uno Platform team is following this [Visual Studio issue](https://developercommunity.visualstudio.com/t/WSL-launch-profile-cannot-be-found-when/10776961).

Expand Down
8 changes: 8 additions & 0 deletions src/Uno.Sdk/targets/Uno.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,12 @@
<EmbeddedResource Include="appsettings.json" />
<EmbeddedResource Include="appsettings.*.json" DependentUpon="appsettings.json" />
</ItemGroup>

<!-- Enable WSL support in VS 17.13 Pre 2 and later, when a desktop target is present -->
<ItemGroup Condition="
$([MSBuild]::VersionGreaterThanOrEquals($(MSBuildVersion), 17.13.0))
AND '$(TargetFrameworks)' != ''
AND $(TargetFrameworks.Contains('desktop')) ">
<ProjectCapability Include="DotNetWslLaunch" />
</ItemGroup>
</Project>
5 changes: 3 additions & 2 deletions src/Uno.Sdk/targets/Uno.Sdk.After.targets
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
AND '$(BuildingInsideVisualStudio)' == 'true'
AND '$(OutputType)'!='Library'
AND $([MSBuild]::VersionGreaterThanOrEquals($(MSBuildVersion), 17.12.0))
AND $([MSBuild]::VersionLessThan($(MSBuildVersion), 17.13.0))
AND '$(_UnoTargetFrameworkCount)' != ''
AND $(_UnoTargetFrameworkCount) &gt; 1
AND $(TargetFrameworks.Contains('-desktop'))
Expand All @@ -136,8 +137,8 @@
)
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)" />
<Warning Code="UNOB0015"
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/UNOB0015)" />
</Target>

<Target Name="_UnoVSWarnWindowsIsFirst"
Expand Down

0 comments on commit e3f600f

Please sign in to comment.