File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ import { CSharpExtensionId } from '../constants/csharpExtensionId';
1515import { promisify } from 'util' ;
1616import { exec } from 'child_process' ;
1717import { getDotnetInfo } from '../shared/utils/getDotnetInfo' ;
18- import { readFile } from 'fs/promises' ;
18+ import { readFile , readlink } from 'fs/promises' ;
1919
2020export const DotNetRuntimeVersion = '7.0' ;
2121
@@ -163,13 +163,23 @@ export class DotnetRuntimeExtensionResolver implements IHostExecutableResolver {
163163 throw new Error ( `Unable to find dotnet from ${ command } .` ) ;
164164 }
165165
166- const path = whereOutput . stdout . trim ( ) ;
166+ // There could be multiple paths output from where. Take the first since that is what we used to run dotnet --info.
167+ const path = whereOutput . stdout . trim ( ) . replace ( / \r / gm, '' ) . split ( '\n' ) [ 0 ] ;
167168 if ( ! existsSync ( path ) ) {
168169 throw new Error ( `dotnet path does not exist: ${ path } ` ) ;
169170 }
170171
171172 this . channel . appendLine ( `Using dotnet configured on PATH` ) ;
172- return path ;
173+
174+ // If dotnet is just a symlink, resolve it to the actual executable so
175+ // callers will be able to get the actual directory containing the exe.
176+ try {
177+ const targetPath = await readlink ( path ) ;
178+ return targetPath ;
179+ } catch {
180+ // Not a symlink.
181+ return path ;
182+ }
173183 } catch ( e ) {
174184 this . channel . appendLine (
175185 'Failed to find dotnet info from path, falling back to acquire runtime via ms-dotnettools.vscode-dotnet-runtime'
You can’t perform that action at this time.
0 commit comments