Skip to content

Commit 71423c1

Browse files
authored
Add an AOT compatibility test app (#1378)
* Add an AOT compatibility test app Following the guides at https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/prepare-libraries-for-trimming?pivots=dotnet-8-0 and https://devblogs.microsoft.com/dotnet/creating-aot-compatible-libraries/, add an application which is published for AOT in CI. This process fully verifies all code-paths in the library and its dependencies for trimming/AOT, which the analyzers are not themselves able to do. (As a side benefit, now we are also checking the library builds in Release) * Test failure scenario * Revert "Test failure scenario" This reverts commit 6ff943b.
1 parent 3dc3fc8 commit 71423c1

File tree

7 files changed

+61
-4
lines changed

7 files changed

+61
-4
lines changed

Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Assembly Info properties that apply to all projects/assemblies.
66
-->
77
<PropertyGroup>
8+
<IsPackable>false</IsPackable>
89
<SignAssembly>true</SignAssembly>
910
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)Renci.SshNet.snk</AssemblyOriginatorKeyFile>
1011
<GenerateDocumentationFile>true</GenerateDocumentationFile>

Renci.SshNet.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Renci.SshNet.Benchmarks", "
8484
EndProject
8585
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Renci.SshNet.IntegrationBenchmarks", "test\Renci.SshNet.IntegrationBenchmarks\Renci.SshNet.IntegrationBenchmarks.csproj", "{6DFC1807-3F44-4302-A302-43F7D887C4E0}"
8686
EndProject
87+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Renci.SshNet.AotCompatibilityTestApp", "test\Renci.SshNet.AotCompatibilityTestApp\Renci.SshNet.AotCompatibilityTestApp.csproj", "{F2E3FC50-4EF4-488C-B3D2-C45E99898D8B}"
88+
EndProject
8789
Global
8890
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8991
Debug|Any CPU = Debug|Any CPU
@@ -212,6 +214,26 @@ Global
212214
{6DFC1807-3F44-4302-A302-43F7D887C4E0}.Release|x64.Build.0 = Release|Any CPU
213215
{6DFC1807-3F44-4302-A302-43F7D887C4E0}.Release|x86.ActiveCfg = Release|Any CPU
214216
{6DFC1807-3F44-4302-A302-43F7D887C4E0}.Release|x86.Build.0 = Release|Any CPU
217+
{F2E3FC50-4EF4-488C-B3D2-C45E99898D8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
218+
{F2E3FC50-4EF4-488C-B3D2-C45E99898D8B}.Debug|Any CPU.Build.0 = Debug|Any CPU
219+
{F2E3FC50-4EF4-488C-B3D2-C45E99898D8B}.Debug|ARM.ActiveCfg = Debug|Any CPU
220+
{F2E3FC50-4EF4-488C-B3D2-C45E99898D8B}.Debug|ARM.Build.0 = Debug|Any CPU
221+
{F2E3FC50-4EF4-488C-B3D2-C45E99898D8B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
222+
{F2E3FC50-4EF4-488C-B3D2-C45E99898D8B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
223+
{F2E3FC50-4EF4-488C-B3D2-C45E99898D8B}.Debug|x64.ActiveCfg = Debug|Any CPU
224+
{F2E3FC50-4EF4-488C-B3D2-C45E99898D8B}.Debug|x64.Build.0 = Debug|Any CPU
225+
{F2E3FC50-4EF4-488C-B3D2-C45E99898D8B}.Debug|x86.ActiveCfg = Debug|Any CPU
226+
{F2E3FC50-4EF4-488C-B3D2-C45E99898D8B}.Debug|x86.Build.0 = Debug|Any CPU
227+
{F2E3FC50-4EF4-488C-B3D2-C45E99898D8B}.Release|Any CPU.ActiveCfg = Release|Any CPU
228+
{F2E3FC50-4EF4-488C-B3D2-C45E99898D8B}.Release|Any CPU.Build.0 = Release|Any CPU
229+
{F2E3FC50-4EF4-488C-B3D2-C45E99898D8B}.Release|ARM.ActiveCfg = Release|Any CPU
230+
{F2E3FC50-4EF4-488C-B3D2-C45E99898D8B}.Release|ARM.Build.0 = Release|Any CPU
231+
{F2E3FC50-4EF4-488C-B3D2-C45E99898D8B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
232+
{F2E3FC50-4EF4-488C-B3D2-C45E99898D8B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
233+
{F2E3FC50-4EF4-488C-B3D2-C45E99898D8B}.Release|x64.ActiveCfg = Release|Any CPU
234+
{F2E3FC50-4EF4-488C-B3D2-C45E99898D8B}.Release|x64.Build.0 = Release|Any CPU
235+
{F2E3FC50-4EF4-488C-B3D2-C45E99898D8B}.Release|x86.ActiveCfg = Release|Any CPU
236+
{F2E3FC50-4EF4-488C-B3D2-C45E99898D8B}.Release|x86.Build.0 = Release|Any CPU
215237
EndGlobalSection
216238
GlobalSection(SolutionProperties) = preSolution
217239
HideSolutionNode = FALSE

appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ for:
3636
build_script:
3737
- echo build
3838
- dotnet build Renci.SshNet.sln -c Debug
39+
- dotnet publish -c Release -r win-x64 /warnaserror .\test\Renci.SshNet.AotCompatibilityTestApp\
3940

4041
test_script:
4142
- ps: echo "Run unit tests for .NET 8.0"

src/Renci.SshNet/Renci.SshNet.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
</PropertyGroup>
99

1010
<PropertyGroup>
11+
<IsPackable>true</IsPackable>
1112
<PackageId>SSH.NET</PackageId>
1213
<Title>SSH.NET</Title>
1314
<Version>2024.0.0</Version>
@@ -24,9 +25,7 @@
2425
</PropertyGroup>
2526

2627
<PropertyGroup Condition=" $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0')) ">
27-
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
28-
<EnableSingleFileAnalyzer>true</EnableSingleFileAnalyzer>
29-
<EnableAotAnalyzer>true</EnableAotAnalyzer>
28+
<IsAotCompatible>true</IsAotCompatible>
3029
</PropertyGroup>
3130

3231
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' or '$(TargetFramework)' == 'netstandard2.0' ">
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
3+
namespace Renci.SshNet.AotCompatibilityTestApp
4+
{
5+
public static class Program
6+
{
7+
public static void Main()
8+
{
9+
// This app is used to verify the trim- and AOT-friendliness of
10+
// the library and its dependencies, by specifying <TrimmerRootAssembly>
11+
// in the csproj and publishing with e.g. "dotnet publish -c Release -r win-x64"
12+
13+
// See https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/prepare-libraries-for-trimming?pivots=dotnet-8-0
14+
// and https://devblogs.microsoft.com/dotnet/creating-aot-compatible-libraries/
15+
16+
Console.WriteLine("Hello, AOT!");
17+
}
18+
}
19+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<PublishAot>true</PublishAot>
7+
<SelfContained>true</SelfContained>
8+
<TrimmerSingleWarn>false</TrimmerSingleWarn>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<ProjectReference Include="..\..\src\Renci.SshNet\Renci.SshNet.csproj" />
13+
<TrimmerRootAssembly Include="Renci.SshNet" />
14+
</ItemGroup>
15+
16+
</Project>

test/Renci.SshNet.IntegrationTests/Renci.SshNet.IntegrationTests.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<PropertyGroup>
44
<TargetFrameworks>net48;net8.0</TargetFrameworks>
55
<ImplicitUsings>enable</ImplicitUsings>
6-
<IsPackable>false</IsPackable>
76
<IsTestProject>true</IsTestProject>
87
<NoWarn>$(NoWarn);SYSLIB0021;SYSLIB1045;SYSLIB0014;IDE0220;IDE0010</NoWarn>
98
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>

0 commit comments

Comments
 (0)