Skip to content

Commit 619f885

Browse files
committed
Fix default package zip file when packaging file-baded function
1 parent d46e49b commit 619f885

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/Amazon.Lambda.Tools/LambdaPackager.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,22 +237,30 @@ public static bool CreateApplicationBundle(LambdaToolsDefaults defaults, IToolLo
237237
// If there is no target node then this means the tool is being used on a future version of .NET Core
238238
// then was available when the this tool was written. Go ahead and continue the deployment with warnings so the
239239
// user can see if the future version will work.
240-
if (depsJsonTargetNode.HasValue && string.Equals(targetFramework, "netcoreapp1.0", StringComparison.OrdinalIgnoreCase))
240+
if (depsJsonTargetNode.HasValue && string.Equals(targetFramework, "netcoreapp1.0", StringComparison.OrdinalIgnoreCase))
241241
{
242242
// Make sure the project is not pulling in dependencies requiring a later version of .NET Core then the declared target framework
243-
if (!ValidateDependencies(logger, targetFramework, depsJsonTargetNode.Value, disableVersionCheck))
243+
if (!ValidateDependencies(logger, targetFramework, depsJsonTargetNode.Value, disableVersionCheck))
244244
return false;
245245

246246
// Flatten the runtime folder which reduces the package size by not including native dependencies
247247
// for other platforms.
248-
flattenRuntime = FlattenRuntimeFolder(logger, publishLocation, depsJsonTargetNode.Value);
248+
flattenRuntime = FlattenRuntimeFolder(logger, publishLocation, depsJsonTargetNode.Value);
249249
}
250250
}
251251

252252
FlattenPowerShellRuntimeModules(logger, publishLocation, targetFramework);
253253

254254
if (zipArchivePath == null)
255-
zipArchivePath = Path.Combine(Directory.GetParent(publishLocation).FullName, new DirectoryInfo(projectLocation).Name + ".zip");
255+
{
256+
string baseName;
257+
if (Utilities.IsSingleFileCSharpFile(projectLocation))
258+
baseName = Path.GetFileNameWithoutExtension(projectLocation);
259+
else
260+
baseName = new DirectoryInfo(projectLocation).Name;
261+
262+
zipArchivePath = Path.Combine(Directory.GetParent(publishLocation).FullName, baseName + ".zip");
263+
}
256264

257265
zipArchivePath = Path.GetFullPath(zipArchivePath);
258266
logger?.WriteLine($"Zipping publish folder {publishLocation} to {zipArchivePath}");

0 commit comments

Comments
 (0)