@@ -21,7 +21,6 @@ async function generateCsAddonFiles(options = {}) {
2121 // Validate addon name (should be a valid C# namespace/class name)
2222 validateAddonName ( name ) ;
2323
24-
2524 await checkAndInstallVisualStudioBuildTools ( false ) ; // Don't show verbose build tools info
2625
2726 // Check if dotnet SDK is available and offer to install if missing
@@ -361,6 +360,14 @@ async function updateGitignore(projectRoot, verbose) {
361360 }
362361}
363362
363+ /**
364+ * Get the winget command line for installing .NET 10 SDK
365+ * @returns {string } The winget command line
366+ */
367+ function getDotnet10SdkWingetCommand ( ) {
368+ return 'winget install --id Microsoft.DotNet.SDK.10 --source winget' ;
369+ }
370+
364371/**
365372 * Check for .NET 10 SDK and offer to install if missing
366373 * @param {boolean } verbose - Enable verbose logging
@@ -370,6 +377,10 @@ async function checkAndInstallDotnet10Sdk(verbose = false, addonName = 'csAddon'
370377 const hasDotnet10 = await checkDotnetSdk ( verbose ) ;
371378 if ( ! hasDotnet10 ) {
372379 console . log ( '.NET 10 SDK is required for C# addons but was not found.' ) ;
380+ console . log ( '' ) ;
381+ console . log ( 'The following command will be run:' ) ;
382+ console . log ( ' ' + getDotnet10SdkWingetCommand ( ) ) ;
383+ console . log ( '' ) ;
373384
374385 // Check if we're in an interactive terminal
375386 if ( process . stdin . isTTY ) {
@@ -422,7 +433,8 @@ function installDotnet10Sdk() {
422433 const { spawn } = require ( 'child_process' ) ;
423434
424435 // Use winget to install .NET 10 SDK
425- const winget = spawn ( 'winget' , [ 'install' , '--id' , 'Microsoft.DotNet.SDK.10' , '--source' , 'winget' ] , {
436+ const command = getDotnet10SdkWingetCommand ( ) ;
437+ const winget = spawn ( command , {
426438 stdio : 'inherit' ,
427439 shell : true
428440 } ) ;
@@ -438,6 +450,14 @@ function installDotnet10Sdk() {
438450 } ) ;
439451}
440452
453+ /**
454+ * Get the winget command line for installing Visual Studio Build Tools
455+ * @returns {string } The winget command line
456+ */
457+ function getVisualStudioBuildToolsWingetCommand ( ) {
458+ return 'winget install --id Microsoft.VisualStudio.Community --source winget --override "--add Microsoft.VisualStudio.Workload.NativeDesktop --passive --wait"' ;
459+ }
460+
441461/**
442462 * Check for Visual Studio Build Tools and offer to install if missing
443463 * @param {boolean } verbose - Enable verbose logging
@@ -446,6 +466,10 @@ async function checkAndInstallVisualStudioBuildTools(verbose = false) {
446466 const hasVisualStudioBuildTools = checkVisualStudioBuildTools ( ) ;
447467 if ( ! hasVisualStudioBuildTools ) {
448468 console . log ( 'Visual Studio Build Tools are required for C# addons but were not found.' ) ;
469+ console . log ( '' ) ;
470+ console . log ( 'The following command will be run:' ) ;
471+ console . log ( ' ' + getVisualStudioBuildToolsWingetCommand ( ) ) ;
472+ console . log ( '' ) ;
449473
450474 // Check if we're in an interactive terminal
451475 if ( process . stdin . isTTY ) {
@@ -536,15 +560,8 @@ function installVisualStudioBuildTools() {
536560 const { spawn } = require ( 'child_process' ) ;
537561
538562 // Use winget to install Visual Studio Community with Native Desktop workload
539- const winget = spawn ( 'winget' , [
540- 'install' ,
541- '--id' ,
542- 'Microsoft.VisualStudio.Community' ,
543- '--source' ,
544- 'winget' ,
545- '--override' ,
546- '--add Microsoft.VisualStudio.Workload.NativeDesktop --passive --wait'
547- ] , {
563+ const command = getVisualStudioBuildToolsWingetCommand ( ) ;
564+ const winget = spawn ( command , {
548565 stdio : 'inherit' ,
549566 shell : true
550567 } ) ;
0 commit comments