Build: Merging windows and linux targets for the windows host because VS does not support the import

This commit is contained in:
Zoe Roux 2021-09-05 19:41:08 +02:00
parent 61439695a8
commit aef5ce59cb
5 changed files with 52 additions and 70 deletions

View File

@ -28,7 +28,7 @@ namespace Kyoo.Authentication
}
/// <summary>
/// Convert a user to an <see cref="IdentityServerUser"/>.
/// Convert a user to an IdentityServerUser.
/// </summary>
/// <param name="user">The user to convert.</param>
/// <returns>The corresponding identity server user.</returns>

View File

@ -1,12 +1,43 @@
<Project>
<Project ToolsVersion="Current">
<PropertyGroup>
<ProjectGuid>{98851001-40DD-46A6-94B3-2F8D90722076}</ProjectGuid>
<IsWindows Condition="$([MSBuild]::IsOSPlatform('Windows'))">true</IsWindows>
</PropertyGroup>
<Import Project="Kyoo.Host.WindowsTrait.target" Condition="$(IsWindows) == true" />
<Import Project="Kyoo.Host.WindowsTrait.linux.target" Condition="$(IsWindows) != true" />
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<ItemGroup>
<None Remove="*.target" />
<PropertyGroup Condition="$(IsWindows) == true">
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<RootNamespace>Kyoo.WindowsHost</RootNamespace>
</PropertyGroup>
<ItemGroup Condition="$(IsWindows) == true">
<ProjectReference Include="../Kyoo.Core/Kyoo.Core.csproj" />
<ProjectReference Include="../Kyoo.Host.Console/Kyoo.Host.Console.csproj" Condition="$(IncludeConsole) == true" />
<None Remove="kyoo.ico" />
<Content Include="kyoo.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<PropertyGroup Condition="$(IsWindows) != true">
<TargetFramework>net5.0</TargetFramework>
<NoWarn>NU1503</NoWarn>
</PropertyGroup>
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
<Target Name="Build" Condition="$(IsWindows) != true">
<Message Importance="high" Text="Detected current operating system is not windows, skipping WindowsHost build." />
</Target>
<Target Name="Clean" Condition="$(IsWindows) != true" />
<Target Name="Pack" Condition="$(IsWindows) != true" />
<Target Name="Restore" Condition="$(IsWindows) != true" />
<Target Name="Publish" Condition="$(IsWindows) != true" />
<ItemGroup Condition="$(IsWindows) != true">
<None Include="@(Compile)" Visible="true" />
<Compile Remove="*" />
</ItemGroup>
</Project>

View File

@ -1,26 +0,0 @@
<Project>
<!-- Project file used instead of the default csproj when the host system is not windows. This only skip the build. -->
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<NoWarn>NU1503</NoWarn>
</PropertyGroup>
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
<Target Name="Build">
<Message Importance="high" Text="Detected current operating system is not windows, skipping WindowsHost build." />
</Target>
<Target Name="Clean" />
<Target Name="Pack" />
<Target Name="Restore" />
<Target Name="Publish" />
<ItemGroup>
<None Include="@(Compile)" Visible="true" />
<Compile Remove="*" />
</ItemGroup>
</Project>

View File

@ -1,24 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<!-- Project file used instead of the default csproj when the host system is windows.
This is the real csproj used to compile the project.
-->
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<RootNamespace>Kyoo.WindowsHost</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="../Kyoo.Core/Kyoo.Core.csproj" />
<ProjectReference Include="../Kyoo.Host.Console/Kyoo.Host.Console.csproj" Condition="$(IncludeConsole) == true" />
</ItemGroup>
<ItemGroup>
<None Remove="kyoo.ico"/>
<Content Include="kyoo.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

View File

@ -25,13 +25,12 @@ namespace Kyoo.Host.WindowsTrait
/// The options containing the <see cref="BasicOptions.PublicUrl"/>.
/// </summary>
private readonly IOptions<BasicOptions> _options;
/// <summary>
/// The thread where the trait is running.
/// </summary>
private Thread _thread;
/// <summary>
/// Create a new <see cref="SystemTrait"/>.
/// </summary>
@ -42,7 +41,7 @@ namespace Kyoo.Host.WindowsTrait
_application = application;
_options = options;
}
/// <inheritdoc />
public void Start()
{
@ -73,12 +72,12 @@ namespace Kyoo.Host.WindowsTrait
private readonly IApplication _application;
/// <summary>
/// The options containing the <see cref="BasicOptions.PublicUrl"/>.
/// </summary>
/// The options containing the <see cref="BasicOptions.PublicUrl"/>.
/// </summary>
private readonly IOptions<BasicOptions> _options;
/// <summary>
/// The Icon that is displayed in the window's bar.
/// The Icon that is displayed in the window's bar.
/// </summary>
private readonly NotifyIcon _icon;
@ -95,10 +94,12 @@ namespace Kyoo.Host.WindowsTrait
AppDomain.CurrentDomain.ProcessExit += (_, _) => Dispose();
System.Windows.Forms.Application.ApplicationExit += (_, _) => Dispose();
_icon = new NotifyIcon();
_icon.Text = "Kyoo";
_icon.Icon = new Icon(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "kyoo.ico"));
_icon.Visible = true;
_icon = new NotifyIcon
{
Text = "Kyoo",
Icon = new Icon(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "kyoo.ico")),
Visible = true
};
_icon.MouseClick += (_, e) =>
{
if (e.Button != MouseButtons.Left)
@ -160,4 +161,4 @@ namespace Kyoo.Host.WindowsTrait
}
}
}
}
}