Merge pull request #17533 from unoplatform/dev/jela/rider-error

fix: Fail build on Rider IDE using unsupported targets
This commit is contained in:
Jérôme Laban 2024-07-15 23:33:57 -04:00 коммит произвёл GitHub
Родитель f22e641677 3a3eb94985
Коммит d334b5d1c7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 59 добавлений и 4 удалений

Просмотреть файл

@ -29,11 +29,8 @@ Creating an Uno Platform project is done [using dotnet new](xref:Uno.GetStarted.
1. In your terminal, navigate to the folder that will contain your new app.
> [!IMPORTANT]
> As of Rider 2023.3, the Uno Platform 5.2 `net8.0-browserwasm` and `net8.0-desktop` TargetFrameworks are not supported. See [this JetBrains article](https://aka.platform.uno/rider-desktop-wasm-support) for more details.
> To build an app using Uno Platform 5.1 templates that are compatible with Rider, run `dotnet new uninstall uno.templates` then `dotnet new install uno.templates::5.1.25`.
1. Create a new project by pasting the command that was previously generated in the Live Wizard.
1. Open the solution in Rider, you should now have a folder structure that looks like this:
![A screen showing the structure of the solution in Rider](Assets/quick-start/rider-folder-structure.png)
@ -41,6 +38,28 @@ Creating an Uno Platform project is done [using dotnet new](xref:Uno.GetStarted.
> [!TIP]
> If you are not able to run the online Live Wizard, you can explore the [`dotnet new` template](xref:Uno.GetStarted.dotnet-new) directly in the CLI.
### Considerations for macOS and Linux
When using macOS or Linux for developing your application and you have selected the WinAppSDK target, you may get the **UNOB0014** error which mentions building on macOS or Linux is not supported. While Uno Platform is able to filter out unsupported targets from the command line and other IDE, Rider currently [does not support this automatic filtering](https://youtrack.jetbrains.com/issue/RIDER-114790/Unsupported-target-framework-filtering).
To correct this, you'll need to modify your `csproj` file in order to make the project compatible.
You can change this line:
```xml
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst;net8.0-windows10.0.19041;net8.0-browserwasm;net8.0-desktop</TargetFrameworks>
```
To be:
```xml
<TargetFrameworks>net8.0-android;net8.0-browserwasm;net8.0-desktop</TargetFrameworks>
<TargetFrameworks Condition=" $([MSBuild]::IsOSPlatform('windows')) ">$(TargetFrameworks);net8.0-windows10.0.19041</TargetFrameworks>
<TargetFrameworks Condition=" !$([MSBuild]::IsOSPlatform('linux')) ">$(TargetFrameworks);net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
```
Make sure to adjust the list of target frameworks based on the platforms you have in your original list.
## Debug the App
### [**Desktop**](#tab/desktop)

Просмотреть файл

@ -123,6 +123,12 @@ This warning can be disabled by adding the following to your `.csproj`:
</PropertyGroup>
```
### UNOB0014: The target framework is not supported on macOS or Linux
When building with Rider on Linux or macOS, unsupported target frameworks are [not filtered automatically like other IDEs](https://youtrack.jetbrains.com/issue/RIDER-114790/Unsupported-target-framework-filtering).
See how to [make platforms conditional](xref:Uno.GettingStarted.CreateAnApp.Rider#considerations-for-macos-and-linux) for Rider.
## Compiler Errors
### UNO0001

Просмотреть файл

@ -111,6 +111,36 @@
</ItemGroup>
</Target>
<Target Name="UnoFailOnUnsupportedTargetFrameworks"
Condition=" '$(UnoDisableRemoveUnsupportedTargetFrameworks)' != 'true' "
BeforeTargets="BeforeBuild">
<!--
This target is primarily used for Rider, which does not support
UnoRemoveUnsupportedTargetFrameworks to filter frameworks.
-->
<Error Code="UNOB0014"
HelpLink="https://aka.platform.uno/UNOB0014"
Text="Building for Windows is not supported on non-Windows systems. See for more details: https://aka.platform.uno/UNOB0014"
Condition="
!$([MSBuild]::IsOSPlatform('windows'))
AND '$(IsUnoHead)' == 'true'
AND '$(IsWinAppSdk)' == 'true' " />
<Error Code="UNOB0014"
HelpLink="https://aka.platform.uno/UNOB0014"
Text="Building for Apple platforms is not supported on Linux. See for more details: https://aka.platform.uno/UNOB0014"
Condition="
$([MSBuild]::IsOSPlatform('linux'))
AND (
$([MSBuild]::GetTargetPlatformIdentifier($(TargetFramework))) == 'ios'
OR $([MSBuild]::GetTargetPlatformIdentifier($(TargetFramework))) == 'maccatalyst'
)" />
</Target>
<Import Project="Uno.SingleProject.VS.Build.targets"
Condition=" '$(UnoSingleProject)' == 'true' AND '$(BuildingInsideVisualStudio)' == 'true' " />
</Project>