Skip to content

Commit b378ac5

Browse files
authored
fix(sam): remove .NET core 3.1 #3859
No longer supported by Lambda. https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html
1 parent 398744e commit b378ac5

File tree

12 files changed

+46
-52
lines changed

12 files changed

+46
-52
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Deprecation",
3+
"description": "SAM: removed support for .NET core 3.1 [Lambda runtime](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html)"
4+
}

src/lambda/local/debugConfiguration.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import globals from '../../shared/extensionGlobals'
2525
* Magic path on the Docker image.
2626
* https://github.com/aws/aws-sam-cli/blob/2201b17bff0a438b934abbb53f6c76eff9ccfa6d/samcli/local/docker/lambda_container.py#L25
2727
*/
28-
export const dotnetCoreDebuggerPath = '/tmp/lambci_debug_files/vsdbg'
28+
export const dotnetDebuggerPath = '/tmp/lambci_debug_files/vsdbg'
2929
export const goDebuggerPath = '/tmp/lambci_debug_files'
3030

3131
export interface NodejsDebugConfiguration extends SamLaunchRequestArgs {
@@ -68,8 +68,8 @@ export interface PythonCloud9DebugConfiguration extends SamLaunchRequestArgs {
6868
readonly remoteRoot: string
6969
}
7070

71-
export interface DotNetCoreDebugConfiguration extends SamLaunchRequestArgs {
72-
readonly runtimeFamily: RuntimeFamily.DotNetCore
71+
export interface DotNetDebugConfiguration extends SamLaunchRequestArgs {
72+
readonly runtimeFamily: RuntimeFamily.DotNet
7373
processName: string
7474
pipeTransport: PipeTransport
7575
windows: {
@@ -90,7 +90,7 @@ export interface GoDebugConfiguration extends SamLaunchRequestArgs {
9090
export interface PipeTransport {
9191
pipeProgram: 'sh' | 'powershell'
9292
pipeArgs: string[]
93-
debuggerPath: typeof dotnetCoreDebuggerPath
93+
debuggerPath: typeof dotnetDebuggerPath
9494
pipeCwd: string
9595
}
9696

src/lambda/models/samLambdaRuntime.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export enum RuntimeFamily {
1919
Unknown,
2020
Python,
2121
NodeJS,
22-
DotNetCore,
22+
DotNet,
2323
Go,
2424
Java,
2525
}
@@ -52,7 +52,7 @@ export const pythonRuntimes: ImmutableSet<Runtime> = ImmutableSet<Runtime>([
5252
])
5353
export const goRuntimes: ImmutableSet<Runtime> = ImmutableSet<Runtime>(['go1.x'])
5454
export const javaRuntimes: ImmutableSet<Runtime> = ImmutableSet<Runtime>(['java11', 'java8', 'java8.al2'])
55-
export const dotNetRuntimes: ImmutableSet<Runtime> = ImmutableSet<Runtime>(['dotnetcore3.1', 'dotnet6'])
55+
export const dotNetRuntimes: ImmutableSet<Runtime> = ImmutableSet<Runtime>(['dotnet6'])
5656

5757
/**
5858
* Deprecated runtimes can be found at https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html
@@ -74,7 +74,7 @@ export const deprecatedRuntimes: ImmutableSet<Runtime> = ImmutableSet<Runtime>([
7474
const defaultRuntimes = ImmutableMap<RuntimeFamily, Runtime>([
7575
[RuntimeFamily.NodeJS, 'nodejs14.x'],
7676
[RuntimeFamily.Python, 'python3.9'],
77-
[RuntimeFamily.DotNetCore, 'dotnetcore3.1'],
77+
[RuntimeFamily.DotNet, 'dotnet6'],
7878
[RuntimeFamily.Go, 'go1.x'],
7979
[RuntimeFamily.Java, 'java11'],
8080
])
@@ -143,7 +143,7 @@ export function getFamily(runtime: string): RuntimeFamily {
143143
} else if (pythonRuntimes.has(runtime)) {
144144
return RuntimeFamily.Python
145145
} else if (dotNetRuntimes.has(runtime) || runtime === dotnet50) {
146-
return RuntimeFamily.DotNetCore
146+
return RuntimeFamily.DotNet
147147
} else if (goRuntimes.has(runtime)) {
148148
return RuntimeFamily.Go
149149
} else if (javaRuntimes.has(runtime)) {
@@ -192,7 +192,7 @@ export function getRuntimeFamily(langId: string): RuntimeFamily {
192192
case 'javascript':
193193
return RuntimeFamily.NodeJS
194194
case 'csharp':
195-
return RuntimeFamily.DotNetCore
195+
return RuntimeFamily.DotNet
196196
case 'python':
197197
return RuntimeFamily.Python
198198
case 'go':
@@ -219,7 +219,7 @@ function getRuntimesForFamily(family: RuntimeFamily): ImmutableSet<Runtime> | un
219219
return nodeJsRuntimes
220220
case RuntimeFamily.Python:
221221
return pythonRuntimes
222-
case RuntimeFamily.DotNetCore:
222+
case RuntimeFamily.DotNet:
223223
return dotNetRuntimes
224224
case RuntimeFamily.Go:
225225
return goRuntimes

src/shared/codelens/codeLensUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ export async function makeCSharpCodeLensProvider(configuration: SamCliSettings):
346346
document,
347347
handlers,
348348
token,
349-
runtimeFamily: RuntimeFamily.DotNetCore,
349+
runtimeFamily: RuntimeFamily.DotNet,
350350
})
351351
},
352352
}

src/shared/sam/cli/samCliValidator.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export const minSamCliVersionForImageSupport = '1.13.0'
1414
export const maxSamCliVersionExclusive = '2.0.0'
1515
export const minSamCliVersionForGoSupport = '1.18.1'
1616
export const minSamCliVersionForArmSupport = '1.33.0'
17-
export const minSamCliVersionForDotnet31Support = '1.4.0'
1817

1918
// Errors
2019
export class InvalidSamCliError extends ToolkitError {}

src/shared/sam/debugger/awsSamDebugger.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ export class SamDebugConfigProvider implements vscode.DebugConfigurationProvider
636636
launchConfig = await pythonDebug.makePythonDebugConfig(launchConfig)
637637
break
638638
}
639-
case RuntimeFamily.DotNetCore: {
639+
case RuntimeFamily.DotNet: {
640640
// Make a DotNet launch-config from the generic config.
641641
launchConfig = await csharpDebug.makeCsharpConfig(launchConfig)
642642
break
@@ -711,7 +711,7 @@ export class SamDebugConfigProvider implements vscode.DebugConfigurationProvider
711711
config.type = 'python'
712712
return await pythonDebug.invokePythonLambda(this.ctx, config as PythonDebugConfiguration)
713713
}
714-
case RuntimeFamily.DotNetCore: {
714+
case RuntimeFamily.DotNet: {
715715
config.type = 'coreclr'
716716
return await csharpDebug.invokeCsharpLambda(this.ctx, config)
717717
}

src/shared/sam/debugger/csharpSamDebug.ts

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
import { chmod, ensureDir, writeFile } from 'fs-extra'
77
import * as os from 'os'
88
import * as path from 'path'
9-
import * as semver from 'semver'
109
import {
11-
DotNetCoreDebugConfiguration,
12-
dotnetCoreDebuggerPath,
10+
DotNetDebugConfiguration,
11+
dotnetDebuggerPath,
1312
getCodeRoot,
1413
isImageLambdaConfig,
1514
} from '../../../lambda/local/debugConfiguration'
@@ -24,8 +23,6 @@ import { HttpResourceFetcher } from '../../resourcefetcher/httpResourceFetcher'
2423
import { getLogger } from '../../logger'
2524
import * as vscode from 'vscode'
2625
import * as nls from 'vscode-nls'
27-
import { getSamCliVersion } from '../cli/samCliContext'
28-
import { minSamCliVersionForDotnet31Support } from '../cli/samCliValidator'
2926
import globals from '../../extensionGlobals'
3027
const localize = nls.loadMessageBundle()
3128

@@ -47,13 +44,19 @@ export async function makeCsharpConfig(config: SamLaunchRequestArgs): Promise<Sa
4744

4845
config = {
4946
...config,
47+
// https://github.com/dotnet/vscode-csharp/blob/a270be4f2f1236d9bc1b31b6214f1672096788b7/src/lsptoolshost/debugger.ts#L45C1-L54
48+
// The "ms-dotnettools.csharp" extension declares:
49+
// - "coreclr" as the debugger type for ".NET 5+ and .NET Core"
50+
// - "dotnet" as the debugger type for "C#"
51+
// but haven't found the actual circumstances when "dotnet" works while "coreclr" doesn't.
52+
// type: config.runtime == 'dotnet5.0' ? 'coreclr' : 'dotnet',
5053
type: 'coreclr',
5154
request: config.noDebug ? 'launch' : 'attach',
52-
runtimeFamily: RuntimeFamily.DotNetCore,
55+
runtimeFamily: RuntimeFamily.DotNet,
5356
}
5457

5558
if (!config.noDebug) {
56-
config = await makeCoreCLRDebugConfiguration(config, originalCodeRoot)
59+
config = await makeDotnetDebugConfiguration(config, originalCodeRoot)
5760
}
5861

5962
return config
@@ -72,20 +75,10 @@ export async function invokeCsharpLambda(ctx: ExtContext, config: SamLaunchReque
7275
config.onWillAttachDebugger = waitForPort
7376

7477
if (!config.noDebug) {
75-
const samCliVersion = await getSamCliVersion(ctx.samCliContext())
76-
// TODO: Remove this when min sam version is >= 1.4.0
77-
if (semver.lt(samCliVersion, minSamCliVersionForDotnet31Support)) {
78+
if (config.architecture === 'arm64') {
7879
vscode.window.showWarningMessage(
7980
localize(
80-
'AWS.output.sam.local.no.net.3.1.debug',
81-
'Debugging dotnetcore3.1 lambdas requires a minimum SAM CLI version of 1.4.0. Function will run locally without debug.'
82-
)
83-
)
84-
config.noDebug = true
85-
} else if (config.architecture === 'arm64') {
86-
vscode.window.showWarningMessage(
87-
localize(
88-
'AWS.output.sam.local.no.arm.net.3.1.debug',
81+
'AWS.sam.noArm.dotnet.debug',
8982
'The vsdbg debugger does not currently support the arm64 architecture. Function will run locally without debug.'
9083
)
9184
)
@@ -215,12 +208,12 @@ function getSamProjectDirPathForFile(filepath: string): string {
215208
}
216209

217210
/**
218-
* Creates a CLR launch-config composed with the given `config`.
211+
* Creates a .NET launch-config composed with the given `config`.
219212
*/
220-
export async function makeCoreCLRDebugConfiguration(
213+
export async function makeDotnetDebugConfiguration(
221214
config: SamLaunchRequestArgs,
222215
codeUri: string
223-
): Promise<DotNetCoreDebugConfiguration> {
216+
): Promise<DotNetDebugConfiguration> {
224217
if (config.noDebug) {
225218
throw Error(`SAM debug: invalid config ${config}`)
226219
}
@@ -265,22 +258,22 @@ export async function makeCoreCLRDebugConfiguration(
265258

266259
return {
267260
...config,
268-
runtimeFamily: RuntimeFamily.DotNetCore,
261+
runtimeFamily: RuntimeFamily.DotNet,
269262
request: 'attach',
270263
// Since SAM CLI 1.0 we cannot assume PID=1. So use processName=dotnet
271264
// instead of processId=1.
272265
processName: 'dotnet',
273266
pipeTransport: {
274267
pipeProgram: 'sh',
275268
pipeArgs,
276-
debuggerPath: dotnetCoreDebuggerPath,
269+
debuggerPath: dotnetDebuggerPath,
277270
pipeCwd: codeUri,
278271
},
279272
windows: {
280273
pipeTransport: {
281274
pipeProgram: 'powershell',
282275
pipeArgs,
283-
debuggerPath: dotnetCoreDebuggerPath,
276+
debuggerPath: dotnetDebuggerPath,
284277
pipeCwd: codeUri,
285278
},
286279
},

src/shared/sam/localLambdaRunner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ export function shouldAppendRelativePathToFuncHandler(runtime: string): boolean
532532
case RuntimeFamily.NodeJS:
533533
case RuntimeFamily.Python:
534534
return true
535-
case RuntimeFamily.DotNetCore:
535+
case RuntimeFamily.DotNet:
536536
return false
537537
// if the runtime exists but for some reason we forgot to cover it here, throw anyway so we remember to cover it
538538
default:

src/test/lambda/local/debugConfiguration.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as fs from 'fs-extra'
1010
import { RuntimeFamily } from '../../../lambda/models/samLambdaRuntime'
1111
import { makeTemporaryToolkitFolder } from '../../../shared/filesystemUtilities'
1212
import { DefaultSamLocalInvokeCommand } from '../../../shared/sam/cli/samCliLocalInvoke'
13-
import { makeCoreCLRDebugConfiguration } from '../../../shared/sam/debugger/csharpSamDebug'
13+
import { makeDotnetDebugConfiguration } from '../../../shared/sam/debugger/csharpSamDebug'
1414
import * as testutil from '../../testUtil'
1515
import { SamLaunchRequestArgs } from '../../../shared/sam/debugger/awsSamDebugger'
1616
import * as pathutil from '../../../shared/utilities/pathUtils'
@@ -43,7 +43,7 @@ describe('makeCoreCLRDebugConfiguration', function () {
4343
name: 'fake-launch-config',
4444
workspaceFolder: fakeWorkspaceFolder,
4545
codeRoot: fakeWorkspaceFolder.uri.fsPath,
46-
runtimeFamily: RuntimeFamily.DotNetCore,
46+
runtimeFamily: RuntimeFamily.DotNet,
4747
type: 'coreclr',
4848
request: 'attach',
4949
// cfnTemplate?: CloudFormation.Template
@@ -73,7 +73,7 @@ describe('makeCoreCLRDebugConfiguration', function () {
7373

7474
async function makeConfig({ codeUri = tempFolder }: { codeUri?: string; port?: number }) {
7575
const fakeLaunchConfig = await makeFakeSamLaunchConfig()
76-
return makeCoreCLRDebugConfiguration(fakeLaunchConfig, codeUri)
76+
return makeDotnetDebugConfiguration(fakeLaunchConfig, codeUri)
7777
}
7878

7979
describe('windows', function () {
@@ -144,7 +144,7 @@ describe('isImageLambdaConfig', function () {
144144
name: 'fake-launch-config',
145145
workspaceFolder: fakeWorkspaceFolder,
146146
codeRoot: fakeWorkspaceFolder.uri.fsPath,
147-
runtimeFamily: RuntimeFamily.DotNetCore,
147+
runtimeFamily: RuntimeFamily.DotNet,
148148
request: 'launch',
149149
type: 'launch',
150150
runtime: 'fakedotnet' as Runtime,
@@ -173,7 +173,7 @@ describe('isImageLambdaConfig', function () {
173173
name: 'fake-launch-config',
174174
workspaceFolder: fakeWorkspaceFolder,
175175
codeRoot: fakeWorkspaceFolder.uri.fsPath,
176-
runtimeFamily: RuntimeFamily.DotNetCore,
176+
runtimeFamily: RuntimeFamily.DotNet,
177177
request: 'launch',
178178
type: 'launch',
179179
runtime: 'fakedotnet' as Runtime,
@@ -199,7 +199,7 @@ describe('isImageLambdaConfig', function () {
199199
name: 'fake-launch-config',
200200
workspaceFolder: fakeWorkspaceFolder,
201201
codeRoot: fakeWorkspaceFolder.uri.fsPath,
202-
runtimeFamily: RuntimeFamily.DotNetCore,
202+
runtimeFamily: RuntimeFamily.DotNet,
203203
request: 'launch',
204204
type: 'launch',
205205
runtime: 'fakedotnet' as Runtime,

src/test/lambda/models/samLambdaRuntime.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ describe('runtimes', function () {
9292
it('vscode', function () {
9393
assert.deepStrictEqual(samLambdaCreatableRuntimes(false).toArray().sort(), [
9494
'dotnet6',
95-
'dotnetcore3.1',
9695
'go1.x',
9796
'java11',
9897
'java8',
@@ -109,7 +108,6 @@ describe('runtimes', function () {
109108
assert.deepStrictEqual(samImageLambdaRuntimes(false).toArray().sort(), [
110109
'dotnet5.0',
111110
'dotnet6',
112-
'dotnetcore3.1',
113111
'go1.x',
114112
'java11',
115113
'java8',

0 commit comments

Comments
 (0)