Skip to content

Commit

Permalink
Merge pull request #772 from dorssel/native_aot
Browse files Browse the repository at this point in the history
Use Native AOT
  • Loading branch information
dorssel committed Nov 20, 2023
2 parents 29760e4 + 5a058e6 commit 13ef2bf
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 45 deletions.
37 changes: 29 additions & 8 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,42 @@ SPDX-FileCopyrightText: 2021 Frans van Dorsselaer
SPDX-License-Identifier: GPL-3.0-only
-->
<Project>

<!-- Sane defaults; override in project where needed -->

<PropertyGroup>
<!-- Use the latest .NET SDK -->
<!-- This product requires Windows 10 (Windows Server 2019) or higher -->
<MainTargetFramework>net8.0-windows10.0.17763</MainTargetFramework>
</PropertyGroup>

<!-- Sane defaults; override in project where needed -->

<PropertyGroup Condition="$(TargetFramework) == 'netstandard2.0'">
<!-- For PowerShell, we support everything -->
<Platforms>AnyCPU</Platforms>
<Platform>AnyCPU</Platform>
<IsTrimmable>false</IsTrimmable>
</PropertyGroup>

<PropertyGroup Condition="$(TargetFramework) != 'netstandard2.0'">
<!-- This product only supports x64 (the only architecture supported by VBoxUsb) -->
<Platforms>x64</Platforms>
<Platform>x64</Platform>
<IsTrimmable>true</IsTrimmable>
<!--
<IsAotCompatible>true</IsAotCompatible>
-->
</PropertyGroup>

<!-- Use the latest .NET SDK -->
<!-- This product requires Windows 10 (Windows Server 2019) or higher -->
<TargetFramework>net8.0-windows10.0.17763</TargetFramework>
<PropertyGroup>
<!-- This allows building on Linux; however, building the installer requires Windows -->
<EnableWindowsTargeting>true</EnableWindowsTargeting>

<!-- Use the latest C# language standard -->
<LangVersion>12.0</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>

<!-- Be very strict -->
<WarningLevel>5</WarningLevel>
<WarningLevel>9999</WarningLevel>
<Nullable>enable</Nullable>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<AnalysisLevel>latest-all</AnalysisLevel>
Expand All @@ -35,13 +52,17 @@ SPDX-License-Identifier: GPL-3.0-only
<SelfContained>false</SelfContained>
<IsPackable>false</IsPackable>
<IsPublishable>false</IsPublishable>
<IsTrimmable>true</IsTrimmable>

<Product>usbipd-win</Product>
<Company>Frans van Dorsselaer</Company>
<Copyright>Copyright (C) $([System.DateTime]::UtcNow.ToString("yyyy")) $(Company)</Copyright>
</PropertyGroup>

<PropertyGroup Condition="$(Configuration) == 'Release'">
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GitVersion.MsBuild">
<PrivateAssets>all</PrivateAssets>
Expand Down
5 changes: 2 additions & 3 deletions Installer/Installer.wixproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SPDX-License-Identifier: GPL-3.0-only
<UpdateAssemblyInfo>false</UpdateAssemblyInfo>
<OutputName>usbipd-win</OutputName>
<PublishDir>..\Usbipd\bin\publish</PublishDir>
<PowerShellDir>..\Usbipd.PowerShell\bin\$(Configuration)\netstandard2.0\win</PowerShellDir>
<PowerShellDir>..\Usbipd.PowerShell\bin\$(Configuration)\netstandard2.0</PowerShellDir>
<DefineConstants>PublishDir=$(PublishDir);PowerShellDir=$(PowerShellDir);DriversDir=..\Drivers;Year=$([System.DateTime]::UtcNow.ToString("yyyy"))</DefineConstants>
<!-- Suppress WIX1130: DifxApp Driver is deprecated -->
<SuppressSpecificWarnings>1130</SuppressSpecificWarnings>
Expand Down Expand Up @@ -76,7 +76,6 @@ SPDX-License-Identifier: GPL-3.0-only
<Message Importance="high" Text="Publishing pre-built usbipd-win" />
<RemoveDir Directories="..\Usbipd\bin\publish" />
<MakeDir Directories="..\Usbipd\bin\publish" />
<Exec Command="dotnet publish --nologo --no-restore --no-build --configuration $(Configuration) ..\Usbipd" />
<Exec Command="del /s ..\Usbipd\bin\publish\System.CommandLine.resources.dll" />
<Exec Command="dotnet publish --nologo --no-restore --no-build --framework $(MainTargetFramework) ..\Usbipd" />
</Target>
</Project>
17 changes: 0 additions & 17 deletions NetStandard.props

This file was deleted.

1 change: 1 addition & 0 deletions UnitTests/UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SPDX-License-Identifier: GPL-3.0-only
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>$(MainTargetFramework)</TargetFrameworks>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
Expand Down
3 changes: 1 addition & 2 deletions UsbIds/UsbIds.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ SPDX-License-Identifier: GPL-3.0-only
-->
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="..\NetStandard.props" />

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<IsRoslynComponent>true</IsRoslynComponent>
</PropertyGroup>
Expand Down
7 changes: 3 additions & 4 deletions Usbipd.Automation/Usbipd.Automation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ SPDX-License-Identifier: GPL-3.0-only
-->
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="..\NetStandard.props" />

<PropertyGroup>
<TargetFrameworks>net8.0-windows10.0.17763;netstandard2.0</TargetFrameworks>
<TargetFramework></TargetFramework>
<TargetFrameworks>$(MainTargetFramework);netstandard2.0</TargetFrameworks>
<Platforms>AnyCPU</Platforms>
<Platform>AnyCPU</Platform>
</PropertyGroup>

<ItemGroup>
Expand Down
6 changes: 2 additions & 4 deletions Usbipd.PowerShell/Usbipd.PowerShell.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ SPDX-License-Identifier: GPL-3.0-only
-->
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="..\NetStandard.props" />

<PropertyGroup>
<RuntimeIdentifier>win</RuntimeIdentifier>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="PowerShellStandard.Library">
<PrivateAssets>all</PrivateAssets>
Expand Down
2 changes: 1 addition & 1 deletion Usbipd/DeviceFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void OnCompletion(uint errorCode, uint numBytes, NativeOverlapped* nativeOverlap
{
taskCompletionSource.SetException(new Win32Exception((int)errorCode, $"DeviceIoControl returned error {(WIN32_ERROR)errorCode}"));
}
Overlapped.Free(nativeOverlapped);
BoundHandle.FreeNativeOverlapped(nativeOverlapped);
}

var nativeOverlapped = BoundHandle.AllocateNativeOverlapped(OnCompletion, null, new object?[] { input, output });
Expand Down
9 changes: 4 additions & 5 deletions Usbipd/Properties/PublishProfiles/InputForInstaller.pubxml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ SPDX-License-Identifier: GPL-3.0-only
<Platform>x64</Platform>
<PublishDir>bin\publish\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>net8.0-windows10.0.17763</TargetFramework>
<TargetFramework>$(MainTargetFramework)</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishTrimmed>True</PublishTrimmed>
<SelfContained>false</SelfContained>
<PublishSingleFile>false</PublishSingleFile>
<PublishReadyToRun>false</PublishReadyToRun>
</PropertyGroup>
</Project>
10 changes: 9 additions & 1 deletion Usbipd/Usbipd.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ SPDX-License-Identifier: GPL-3.0-only
<Project Sdk="Microsoft.NET.Sdk.Worker">

<PropertyGroup>
<TargetFrameworks>$(MainTargetFramework)</TargetFrameworks>
<OutputType>Exe</OutputType>
<ApplicationManifest>app.manifest</ApplicationManifest>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>

<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

<IsPublishable>true</IsPublishable>
<PublishProfile>Properties\PublishProfiles\InputForInstaller.pubxml</PublishProfile>
<PublishAot>true</PublishAot>

<AssemblyName>usbipd</AssemblyName>
</PropertyGroup>
Expand Down Expand Up @@ -42,4 +43,11 @@ SPDX-License-Identifier: GPL-3.0-only
</None>
</ItemGroup>

<Target Name="RemoveTranslations" BeforeTargets="Build">
<ItemGroup>
<Translations Include="$(OutputPath)\**\System.CommandLine.resources.dll"/>
</ItemGroup>
<RemoveDir Directories="@(Translations->DirectoryName())" />
</Target>

</Project>

0 comments on commit 13ef2bf

Please sign in to comment.