Skip to content

Commit ce5489e

Browse files
authored
Merge pull request #19382 from unoplatform/mergify/bp/release/stable/5.6/pr-19373
fix: Use newer project capability for WSL in VS 17.13 (backport #19373)
2 parents 3a927d5 + 90201d1 commit ce5489e

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

doc/articles/uno-build-error-codes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,15 @@ See how to [make platforms conditional](xref:Uno.GettingStarted.CreateAnApp.Ride
131131

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

134-
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.
134+
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.
135135

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

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

142-
To fix the issue, reorder the items in your `.csproj` so that `TargetFrameworks` contains `netX.0-desktop` as the first target framework.
142+
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).
143143

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

src/Uno.Sdk/targets/Uno.Common.targets

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,12 @@
142142
<EmbeddedResource Include="appsettings.json" />
143143
<EmbeddedResource Include="appsettings.*.json" DependentUpon="appsettings.json" />
144144
</ItemGroup>
145+
146+
<!-- Enable WSL support in VS 17.13 Pre 2 and later, when a desktop target is present -->
147+
<ItemGroup Condition="
148+
$([MSBuild]::VersionGreaterThanOrEquals($(MSBuildVersion), 17.13.0))
149+
AND '$(TargetFrameworks)' != ''
150+
AND $(TargetFrameworks.Contains('desktop')) ">
151+
<ProjectCapability Include="DotNetWslLaunch" />
152+
</ItemGroup>
145153
</Project>

src/Uno.Sdk/targets/Uno.Sdk.After.targets

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
AND '$(BuildingInsideVisualStudio)' == 'true'
127127
AND '$(OutputType)'!='Library'
128128
AND $([MSBuild]::VersionGreaterThanOrEquals($(MSBuildVersion), 17.12.0))
129+
AND $([MSBuild]::VersionLessThan($(MSBuildVersion), 17.13.0))
129130
AND '$(_UnoTargetFrameworkCount)' != ''
130131
AND $(_UnoTargetFrameworkCount) &gt; 1
131132
AND $(TargetFrameworks.Contains('-desktop'))
@@ -136,8 +137,8 @@
136137
)
137138
AND $([MSBuild]::GetTargetPlatformIdentifier($(_UnoFirstOriginalTargetFramework))) != 'desktop'">
138139

139-
<Warning Code="UNOB0014"
140-
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)" />
140+
<Warning Code="UNOB0015"
141+
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)" />
141142
</Target>
142143

143144
<Target Name="_UnoVSWarnWindowsIsFirst"

0 commit comments

Comments
 (0)