Skip to content

Commit b439801

Browse files
vlesierseVincent Lesierse
andauthored
fix: remove assembly name for PROVIDED_AL2 (#77)
When the Lambda runtime is set to `PROVIDE_AL2` the bundling will set `/p:AssemblyName=bootstrap` to the `dotnet publish` command. However when a project has project references, this condition will also apply to the referenced projects resulting in an error `Ambiguous project name 'bootstrap'`. This fix removes the automatic setting the assembly name. When using this construct to deploy a custom runtime, make sure that the output assembly name is `bootstrap` by either add it to the bundling options `msbuildParameters: ['/p:AssemblyName=bootstrap']` or change the csproj file to include `<AssemblyName>bootstrap</AssemblyName>` Co-authored-by: Vincent Lesierse <[email protected]>
1 parent 8056505 commit b439801

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ new dotnet.DotNetFunction(this, 'MyFunction', {
4545
});
4646
```
4747

48+
Make sure `<AssemblyName>bootstrap</AssemblyName>` is set in the `csproj` file as this is required by the custom runtime.
49+
4850
> Publishing your application with Native AOT requires you to use the same processor architecture for the Lambda function as for your build environment. Without specification, the construct automatically selects the processor architecture of the machine where CDK is building your project.
4951
5052
## Community Extensions

src/private/bundling.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,7 @@ export class Bundling implements cdk.BundlingOptions {
7474

7575
this.msbuildParameters = props.msbuildParameters ?? [];
7676
if (props.runtime.family === RuntimeFamily.OTHER) {
77-
this.msbuildParameters.push(
78-
'--self-contained',
79-
'/p:AssemblyName=bootstrap',
80-
);
77+
this.msbuildParameters.push('--self-contained');
8178
}
8279

8380
const environment = {

test/lambda-handler-aot/LambdaHandler.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<PropertyGroup>
33
<TargetFramework>net7.0</TargetFramework>
44
<OutputType>Exe</OutputType>
5+
<AssemblyName>bootstrap</AssemblyName>
56
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
67
<ImplicitUsings>enable</ImplicitUsings>
78
<Nullable>enable</Nullable>

0 commit comments

Comments
 (0)