6
6
import { chmod , ensureDir , writeFile } from 'fs-extra'
7
7
import * as os from 'os'
8
8
import * as path from 'path'
9
- import * as semver from 'semver'
10
9
import {
11
- DotNetCoreDebugConfiguration ,
12
- dotnetCoreDebuggerPath ,
10
+ DotNetDebugConfiguration ,
11
+ dotnetDebuggerPath ,
13
12
getCodeRoot ,
14
13
isImageLambdaConfig ,
15
14
} from '../../../lambda/local/debugConfiguration'
@@ -24,8 +23,6 @@ import { HttpResourceFetcher } from '../../resourcefetcher/httpResourceFetcher'
24
23
import { getLogger } from '../../logger'
25
24
import * as vscode from 'vscode'
26
25
import * as nls from 'vscode-nls'
27
- import { getSamCliVersion } from '../cli/samCliContext'
28
- import { minSamCliVersionForDotnet31Support } from '../cli/samCliValidator'
29
26
import globals from '../../extensionGlobals'
30
27
const localize = nls . loadMessageBundle ( )
31
28
@@ -47,13 +44,19 @@ export async function makeCsharpConfig(config: SamLaunchRequestArgs): Promise<Sa
47
44
48
45
config = {
49
46
...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',
50
53
type : 'coreclr' ,
51
54
request : config . noDebug ? 'launch' : 'attach' ,
52
- runtimeFamily : RuntimeFamily . DotNetCore ,
55
+ runtimeFamily : RuntimeFamily . DotNet ,
53
56
}
54
57
55
58
if ( ! config . noDebug ) {
56
- config = await makeCoreCLRDebugConfiguration ( config , originalCodeRoot )
59
+ config = await makeDotnetDebugConfiguration ( config , originalCodeRoot )
57
60
}
58
61
59
62
return config
@@ -72,20 +75,10 @@ export async function invokeCsharpLambda(ctx: ExtContext, config: SamLaunchReque
72
75
config . onWillAttachDebugger = waitForPort
73
76
74
77
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' ) {
78
79
vscode . window . showWarningMessage (
79
80
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' ,
89
82
'The vsdbg debugger does not currently support the arm64 architecture. Function will run locally without debug.'
90
83
)
91
84
)
@@ -215,12 +208,12 @@ function getSamProjectDirPathForFile(filepath: string): string {
215
208
}
216
209
217
210
/**
218
- * Creates a CLR launch-config composed with the given `config`.
211
+ * Creates a .NET launch-config composed with the given `config`.
219
212
*/
220
- export async function makeCoreCLRDebugConfiguration (
213
+ export async function makeDotnetDebugConfiguration (
221
214
config : SamLaunchRequestArgs ,
222
215
codeUri : string
223
- ) : Promise < DotNetCoreDebugConfiguration > {
216
+ ) : Promise < DotNetDebugConfiguration > {
224
217
if ( config . noDebug ) {
225
218
throw Error ( `SAM debug: invalid config ${ config } ` )
226
219
}
@@ -265,22 +258,22 @@ export async function makeCoreCLRDebugConfiguration(
265
258
266
259
return {
267
260
...config ,
268
- runtimeFamily : RuntimeFamily . DotNetCore ,
261
+ runtimeFamily : RuntimeFamily . DotNet ,
269
262
request : 'attach' ,
270
263
// Since SAM CLI 1.0 we cannot assume PID=1. So use processName=dotnet
271
264
// instead of processId=1.
272
265
processName : 'dotnet' ,
273
266
pipeTransport : {
274
267
pipeProgram : 'sh' ,
275
268
pipeArgs,
276
- debuggerPath : dotnetCoreDebuggerPath ,
269
+ debuggerPath : dotnetDebuggerPath ,
277
270
pipeCwd : codeUri ,
278
271
} ,
279
272
windows : {
280
273
pipeTransport : {
281
274
pipeProgram : 'powershell' ,
282
275
pipeArgs,
283
- debuggerPath : dotnetCoreDebuggerPath ,
276
+ debuggerPath : dotnetDebuggerPath ,
284
277
pipeCwd : codeUri ,
285
278
} ,
286
279
} ,
0 commit comments