Skip to content

Commit fb6d83e

Browse files
committed
add packaging of runtime
1 parent 1efba58 commit fb6d83e

File tree

2 files changed

+65
-2
lines changed

2 files changed

+65
-2
lines changed

Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Amazon.Lambda.TestTool.csproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@
2020
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.7.1" />
2121
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.11" />
2222
<PackageReference Include="BlazorMonaco" Version="3.2.0" />
23+
<PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="1.11.0" />
24+
</ItemGroup>
25+
26+
<ItemGroup>
27+
<None Include="$(OutputPath)Amazon.Lambda.RuntimeSupport.dll" Pack="true" PackagePath="content" Visible="false" />
2328
</ItemGroup>
2429

2530
<ItemGroup>
2631
<EmbeddedResource Include="wwwroot\**" />
2732
<EmbeddedResource Include="Resources\**" />
2833
</ItemGroup>
29-
30-
</Project>
34+
</Project>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using System;
2+
using System.Diagnostics;
3+
using System.IO;
4+
using System.IO.Compression;
5+
using Xunit;
6+
7+
namespace Amazon.Lambda.TestTool.UnitTests;
8+
9+
public class PackagingTests
10+
{
11+
[Fact]
12+
public void VerifyPackageContentsHasRuntimeSupport()
13+
{
14+
string projectPath = Path.Combine(FindSolutionRoot(), "src", "Amazon.Lambda.TestTool", "Amazon.Lambda.TestTool.csproj");
15+
16+
var process = new Process
17+
{
18+
StartInfo = new ProcessStartInfo
19+
{
20+
FileName = "dotnet",
21+
Arguments = $"pack {projectPath} -c Release",
22+
RedirectStandardOutput = true,
23+
UseShellExecute = false,
24+
CreateNoWindow = true,
25+
}
26+
};
27+
28+
process.Start();
29+
string output = process.StandardOutput.ReadToEnd();
30+
process.WaitForExit();
31+
32+
Assert.Equal(0, process.ExitCode);
33+
34+
string packagePath = Directory.GetFiles(Path.GetDirectoryName(projectPath), "*.nupkg", SearchOption.AllDirectories)[0];
35+
36+
using (var archive = ZipFile.OpenRead(packagePath))
37+
{
38+
var runtimeSupportDllEntry = archive.GetEntry("content/Amazon.Lambda.RuntimeSupport.dll");
39+
Assert.NotNull(runtimeSupportDllEntry);
40+
}
41+
}
42+
43+
private string FindSolutionRoot()
44+
{
45+
string currentDirectory = Directory.GetCurrentDirectory();
46+
while (currentDirectory != null)
47+
{
48+
string[] solutionFiles = Directory.GetFiles(currentDirectory, "*.sln");
49+
if (solutionFiles.Length > 0)
50+
{
51+
return currentDirectory;
52+
}
53+
currentDirectory = Directory.GetParent(currentDirectory)?.FullName;
54+
}
55+
throw new Exception("Could not find the solution root directory.");
56+
}
57+
58+
59+
}

0 commit comments

Comments
 (0)