Skip to content

Commit

Permalink
add packaging of runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
gcbeattyAWS committed Dec 4, 2024
1 parent 68b7f8e commit 24795ec
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="1.11.0" />
<PackageReference Include="Blazored.Modal" Version="7.3.1" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.11" />
</ItemGroup>
</ItemGroup>

<ItemGroup>
<None Include="$(OutputPath)Amazon.Lambda.RuntimeSupport.dll" Pack="true" PackagePath="content" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="wwwroot\**" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using Xunit;

namespace Amazon.Lambda.TestTool.UnitTests;

public class PackagingTests
{
[Fact]
public void VerifyPackageContentsHasRuntimeSupport()
{
string projectPath = Path.Combine(FindSolutionRoot(), "src", "Amazon.Lambda.TestTool", "Amazon.Lambda.TestTool.csproj");

var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "dotnet",
Arguments = $"pack {projectPath} -c Release",
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true,
}
};

process.Start();
string output = process.StandardOutput.ReadToEnd();
process.WaitForExit();

Assert.Equal(0, process.ExitCode);

string packagePath = Directory.GetFiles(Path.GetDirectoryName(projectPath), "*.nupkg", SearchOption.AllDirectories)[0];

using (var archive = ZipFile.OpenRead(packagePath))
{
var runtimeSupportDllEntry = archive.GetEntry("content/Amazon.Lambda.RuntimeSupport.dll");
Assert.NotNull(runtimeSupportDllEntry);
}
}

private string FindSolutionRoot()
{
string currentDirectory = Directory.GetCurrentDirectory();
while (currentDirectory != null)
{
string[] solutionFiles = Directory.GetFiles(currentDirectory, "*.sln");
if (solutionFiles.Length > 0)
{
return currentDirectory;
}
currentDirectory = Directory.GetParent(currentDirectory)?.FullName;
}
throw new Exception("Could not find the solution root directory.");
}


}

0 comments on commit 24795ec

Please sign in to comment.