Skip to content

Commit f8aafa1

Browse files
committed
Generate all runtime support dlls in content folder
1 parent f7f37f3 commit f8aafa1

File tree

3 files changed

+152
-22
lines changed

3 files changed

+152
-22
lines changed
Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
2-
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
32
<PropertyGroup>
4-
<Description>A tool to help debug and test your .NET AWS Lambda functions locally.</Description>
3+
<Description>A tool to help debug and test your .NET AWS Lambda functions locally.</Description>
54
<TargetFramework>net8.0</TargetFramework>
65
<Nullable>enable</Nullable>
76
<ImplicitUsings>enable</ImplicitUsings>
87
<Product>AWS .NET Lambda Test Tool</Product>
98
<Copyright>Apache 2</Copyright>
109
<PackageTags>AWS;Amazon;Lambda</PackageTags>
11-
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
10+
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
1211
<IsPackable>true</IsPackable>
1312
<PackAsTool>true</PackAsTool>
1413
<PackageId>Amazon.Lambda.TestTool</PackageId>
@@ -20,15 +19,27 @@
2019
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.7.1" />
2120
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.11" />
2221
<PackageReference Include="BlazorMonaco" Version="3.2.0" />
23-
<PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="1.11.0" />
2422
</ItemGroup>
25-
23+
24+
<ItemGroup>
25+
<ProjectReference Include="..\..\..\..\Libraries\src\Amazon.Lambda.RuntimeSupport\Amazon.Lambda.RuntimeSupport.csproj" />
26+
</ItemGroup>
27+
2628
<ItemGroup>
27-
<None Include="$(OutputPath)Amazon.Lambda.RuntimeSupport.dll" Pack="true" PackagePath="content" Visible="false" />
29+
<RuntimeSupportFramework Include="net5.0;net6.0;net8.0;netstandard2.0" />
2830
</ItemGroup>
2931

32+
<Target Name="ListRuntimeSupportDlls" BeforeTargets="PrepareForBuild">
33+
<ItemGroup>
34+
<Content Include="$(MSBuildThisFileDirectory)..\..\..\..\Libraries\src\Amazon.Lambda.RuntimeSupport\bin\$(Configuration)\%(RuntimeSupportFramework.Identity)\Amazon.Lambda.RuntimeSupport.dll">
35+
<Pack>true</Pack>
36+
<PackagePath>content\%(RuntimeSupportFramework.Identity)</PackagePath>
37+
</Content>
38+
</ItemGroup>
39+
</Target>
40+
3041
<ItemGroup>
3142
<EmbeddedResource Include="wwwroot\**" />
32-
<EmbeddedResource Include="Resources\**" />
43+
<EmbeddedResource Include="Resources\**" />
3344
</ItemGroup>
3445
</Project>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Microsoft Visual Studio Solution File, Format Version 12.00
2+
# Visual Studio Version 17
3+
VisualStudioVersion = 17.5.2.0
4+
MinimumVisualStudioVersion = 10.0.40219.1
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Amazon.Lambda.TestTool", "Amazon.Lambda.TestTool.csproj", "{129F6132-C0B3-6F05-B947-6FC288B0E9D9}"
6+
EndProject
7+
Global
8+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9+
Debug|Any CPU = Debug|Any CPU
10+
Release|Any CPU = Release|Any CPU
11+
EndGlobalSection
12+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
13+
{129F6132-C0B3-6F05-B947-6FC288B0E9D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
14+
{129F6132-C0B3-6F05-B947-6FC288B0E9D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
15+
{129F6132-C0B3-6F05-B947-6FC288B0E9D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
16+
{129F6132-C0B3-6F05-B947-6FC288B0E9D9}.Release|Any CPU.Build.0 = Release|Any CPU
17+
EndGlobalSection
18+
GlobalSection(SolutionProperties) = preSolution
19+
HideSolutionNode = FALSE
20+
EndGlobalSection
21+
GlobalSection(ExtensibilityGlobals) = postSolution
22+
SolutionGuid = {DFCCF963-C635-4341-B013-7CCA0D77559C}
23+
EndGlobalSection
24+
EndGlobal

Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/PackagingTests.cs

Lines changed: 109 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,153 @@
22
using System.Diagnostics;
33
using System.IO;
44
using System.IO.Compression;
5+
using System.Collections.Generic;
6+
using System.Linq;
57
using Xunit;
8+
using Xunit.Abstractions;
69

710
namespace Amazon.Lambda.TestTool.UnitTests;
811

912
public class PackagingTests
1013
{
14+
private readonly ITestOutputHelper _output;
15+
private static readonly string[] ExpectedFrameworks = new[]
16+
{
17+
"net5.0",
18+
"net6.0",
19+
"net8.0",
20+
"netstandard2.0"
21+
};
22+
23+
public PackagingTests(ITestOutputHelper output)
24+
{
25+
_output = output;
26+
}
27+
1128
[Fact]
1229
public void VerifyPackageContentsHasRuntimeSupport()
1330
{
14-
string projectPath = Path.Combine(FindSolutionRoot(), "src", "Amazon.Lambda.TestTool", "Amazon.Lambda.TestTool.csproj");
31+
string solutionRoot = FindSolutionRoot();
32+
string runtimeSupportPath = Path.Combine(solutionRoot, "Libraries", "src", "Amazon.Lambda.RuntimeSupport", "Amazon.Lambda.RuntimeSupport.csproj");
33+
string projectPath = Path.Combine(solutionRoot, "Tools", "LambdaTestTool-v2", "src", "Amazon.Lambda.TestTool", "Amazon.Lambda.TestTool.csproj");
34+
35+
// Build RuntimeSupport first
36+
_output.WriteLine("Building RuntimeSupport...");
37+
var buildProcess = new Process
38+
{
39+
StartInfo = new ProcessStartInfo
40+
{
41+
FileName = "dotnet",
42+
Arguments = $"build {runtimeSupportPath} -c Release",
43+
RedirectStandardOutput = true,
44+
RedirectStandardError = true,
45+
UseShellExecute = false,
46+
CreateNoWindow = true,
47+
}
48+
};
49+
50+
buildProcess.Start();
51+
string buildOutput = buildProcess.StandardOutput.ReadToEnd();
52+
string buildError = buildProcess.StandardError.ReadToEnd();
53+
buildProcess.WaitForExit();
54+
55+
_output.WriteLine("Build Output:");
56+
_output.WriteLine(buildOutput);
57+
if (!string.IsNullOrEmpty(buildError))
58+
{
59+
_output.WriteLine("Build Errors:");
60+
_output.WriteLine(buildError);
61+
}
62+
63+
Assert.Equal(0, buildProcess.ExitCode);
1564

16-
var process = new Process
65+
// Now pack the test tool
66+
_output.WriteLine("\nPacking TestTool...");
67+
var packProcess = new Process
1768
{
1869
StartInfo = new ProcessStartInfo
1970
{
2071
FileName = "dotnet",
2172
Arguments = $"pack {projectPath} -c Release",
2273
RedirectStandardOutput = true,
74+
RedirectStandardError = true,
2375
UseShellExecute = false,
2476
CreateNoWindow = true,
2577
}
2678
};
2779

28-
process.Start();
29-
string output = process.StandardOutput.ReadToEnd();
30-
process.WaitForExit();
80+
packProcess.Start();
81+
string packOutput = packProcess.StandardOutput.ReadToEnd();
82+
string packError = packProcess.StandardError.ReadToEnd();
83+
packProcess.WaitForExit();
3184

32-
Assert.Equal(0, process.ExitCode);
85+
_output.WriteLine("Pack Output:");
86+
_output.WriteLine(packOutput);
87+
if (!string.IsNullOrEmpty(packError))
88+
{
89+
_output.WriteLine("Pack Errors:");
90+
_output.WriteLine(packError);
91+
}
92+
93+
Assert.Equal(0, packProcess.ExitCode);
94+
95+
string packageDir = Path.Combine(Path.GetDirectoryName(projectPath), "bin", "Release");
96+
_output.WriteLine($"Looking for package in: {packageDir}");
97+
98+
var packageFiles = Directory.GetFiles(packageDir, "*.nupkg", SearchOption.AllDirectories);
99+
Assert.True(packageFiles.Length > 0, $"No .nupkg files found in {packageDir}");
33100

34-
string packagePath = Directory.GetFiles(Path.GetDirectoryName(projectPath), "*.nupkg", SearchOption.AllDirectories)[0];
101+
// Rest of the verification code remains the same...
102+
string packagePath = packageFiles[0];
103+
_output.WriteLine($"Found package: {packagePath}");
35104

36105
using (var archive = ZipFile.OpenRead(packagePath))
37106
{
38-
var runtimeSupportDllEntry = archive.GetEntry("content/Amazon.Lambda.RuntimeSupport.dll");
39-
Assert.NotNull(runtimeSupportDllEntry);
107+
var missingFiles = new List<string>();
108+
109+
foreach (var framework in ExpectedFrameworks)
110+
{
111+
var expectedPath = $"content/{framework}/Amazon.Lambda.RuntimeSupport.dll";
112+
var entry = archive.GetEntry(expectedPath);
113+
114+
if (entry == null)
115+
{
116+
missingFiles.Add(expectedPath);
117+
}
118+
}
119+
120+
if (missingFiles.Any())
121+
{
122+
Assert.Fail($"The following RuntimeSupport DLLs are missing from the package:\n" +
123+
string.Join("\n", missingFiles));
124+
}
125+
126+
var actualFrameworkDlls = archive.Entries
127+
.Where(e => e.FullName.Contains("Amazon.Lambda.RuntimeSupport.dll"))
128+
.Select(e => e.FullName)
129+
.ToList();
130+
131+
_output.WriteLine("\nFound DLLs in package:");
132+
foreach (var dll in actualFrameworkDlls)
133+
{
134+
_output.WriteLine(dll);
135+
}
40136
}
41137
}
42138

139+
43140
private string FindSolutionRoot()
44141
{
45142
string currentDirectory = Directory.GetCurrentDirectory();
46143
while (currentDirectory != null)
47144
{
48-
string[] solutionFiles = Directory.GetFiles(currentDirectory, "*.sln*");
49-
if (solutionFiles.Length > 0)
145+
// Look for the aws-lambda-dotnet directory specifically
146+
if (Path.GetFileName(currentDirectory) == "aws-lambda-dotnet")
50147
{
51148
return currentDirectory;
52149
}
53150
currentDirectory = Directory.GetParent(currentDirectory)?.FullName;
54151
}
55-
throw new Exception("Could not find the solution root directory.");
152+
throw new Exception("Could not find the aws-lambda-dotnet root directory.");
56153
}
57-
58-
59154
}

0 commit comments

Comments
 (0)