@@ -259,14 +259,12 @@ export async function activate(context: vscode.ExtensionContext) {
259259 // load project in this workspace
260260 projectExplorer . loadWorkspace ( ) ;
261261
262+ // hook
263+ postLaunchHook ( context ) ;
264+
262265 // launch done
263266 GlobalEvent . emit ( 'extension_launch_done' ) ;
264267 GlobalEvent . emit ( 'globalLog' , newMessage ( 'Info' , 'Embedded IDE launch done' ) ) ;
265-
266- // refresh external tools now
267- ResInstaller . instance ( ) . refreshExternalToolsIndex ( ) . catch ( err => {
268- GlobalEvent . emit ( 'globalLog' , ExceptionToMessage ( err , 'Warning' ) ) ;
269- } ) ;
270268}
271269
272270// this method is called when your extension is deactivated
@@ -275,6 +273,32 @@ export function deactivate() {
275273 StatusBarManager . getInstance ( ) . disposeAll ( ) ;
276274}
277275
276+ function postLaunchHook ( extensionCtx : vscode . ExtensionContext ) {
277+
278+ const resManager = ResManager . instance ( ) ;
279+ const appUsrData = resManager . getAppUsrData ( ) || { } ;
280+ const isFirstLaunch = appUsrData [ 'InstallTime' ] == undefined ;
281+
282+ // is first launch ?
283+ if ( isFirstLaunch ) {
284+
285+ // setup install time
286+ resManager . setAppUsrData ( 'InstallTime' , Date . now ( ) . toString ( ) ) ;
287+
288+ // only enable github proxy for GMT+8:00 by default
289+ const timeZone = Math . floor ( ( new Date ( ) . getTimezoneOffset ( ) / 60 ) * - 1 ) ;
290+ if ( timeZone != 8 ) {
291+ // disable settings: 'EIDE.Repository.UseProxy'
292+ SettingManager . GetInstance ( ) . setConfigValue ( 'Repository.UseProxy' , false ) ;
293+ }
294+ }
295+
296+ // refresh external tools now
297+ ResInstaller . instance ( ) . refreshExternalToolsIndex ( ) . catch ( err => {
298+ GlobalEvent . emit ( 'globalLog' , ExceptionToMessage ( err , 'Warning' ) ) ;
299+ } ) ;
300+ }
301+
278302//////////////////////////////////////////////////
279303// internal vsc-commands funcs
280304//////////////////////////////////////////////////
@@ -704,14 +728,16 @@ async function tryInstallBinaries(binFolder: File, binVersion: string): Promise<
704728
705729let isEnvSetuped : boolean = false ;
706730
707- function exportEnvToSysPath ( ) {
731+ let isExport2ExtensionCtx = false ;
732+
733+ function exportEnvToSysPath ( context ?: vscode . ExtensionContext ) {
708734
709735 const settingManager = SettingManager . GetInstance ( ) ;
710736 const resManager = ResManager . GetInstance ( ) ;
711737 const builderFolder = resManager . getBuilderDir ( ) ;
712738
713739 // export some eide binaries path to system env path
714- const defEnvPath : string [ ] = [
740+ const systemEnvPaths : string [ ] = [
715741 File . normalize ( `${ builderFolder . path } /bin` ) , // builder bin folder
716742 File . normalize ( `${ builderFolder . path } /utils` ) , // utils tool folder
717743 File . normalize ( `${ builderFolder . dir } /scripts` ) ,
@@ -802,22 +828,20 @@ function exportEnvToSysPath() {
802828 }
803829 } ) ;
804830
831+ // append all tools to system env paths
832+ pathList
833+ . filter ( ( env ) => File . IsDir ( env . path ) )
834+ . forEach ( envInfo => {
835+ systemEnvPaths . push ( envInfo . path ) ;
836+ if ( envInfo . extraPath ) {
837+ envInfo . extraPath . forEach ( p => systemEnvPaths . push ( p ) ) ;
838+ }
839+ } ) ;
840+
805841 /* append to System Path if we not */
806842 if ( isEnvSetuped == false ) {
807-
808- // append all tools env paths
809- pathList
810- . filter ( ( env ) => File . IsDir ( env . path ) )
811- . forEach ( envInfo => {
812- defEnvPath . push ( envInfo . path ) ;
813- if ( envInfo . extraPath ) {
814- envInfo . extraPath . forEach ( p => defEnvPath . push ( p ) ) ;
815- }
816- } ) ;
817-
818- // apply to system env path
819- platform . prependToSysEnv ( process . env , defEnvPath ) ;
820843 isEnvSetuped = true ;
844+ platform . prependToSysEnv ( process . env , systemEnvPaths ) ;
821845 }
822846
823847 /* update env key value */
@@ -833,6 +857,24 @@ function exportEnvToSysPath() {
833857 // 你可通过使用喜欢的 shell 将 DOTNET_CLI_TELEMETRY_OPTOUT 环境变量设置为 "1" 或 "true" 来选择退出遥测。
834858 // 阅读有关 .NET CLI 工具遥测的更多信息: https://aka.ms/dotnet-cli-telemetry
835859 process . env [ 'DOTNET_CLI_TELEMETRY_OPTOUT' ] = '1' ; // disable telemetry
860+
861+ //
862+ // export to vscode extension envs
863+ //
864+ if ( context && ! isExport2ExtensionCtx ) {
865+
866+ isExport2ExtensionCtx = true ;
867+
868+ context . environmentVariableCollection . persistent = false ;
869+
870+ context . environmentVariableCollection . prepend ( 'DOTNET_CLI_TELEMETRY_OPTOUT' , '1' ) ;
871+
872+ for ( const env of pathList ) {
873+ if ( File . IsDir ( env . path ) ) {
874+ context . environmentVariableCollection . append ( env . key , env . path ) ;
875+ }
876+ }
877+ }
836878}
837879
838880async function checkAndInstallRuntime ( ) {
@@ -1033,15 +1075,15 @@ async function InitComponents(context: vscode.ExtensionContext): Promise<boolean
10331075 // register telemetry hook if user enabled
10341076 try {
10351077 if ( settingManager . isEnableTelemetry ( ) ) {
1036- const TelemetryTask = require ( './Telemetry /TelemetryTask' ) ;
1078+ const TelemetryTask = require ( './Private /TelemetryTask' ) ;
10371079 TelemetryTask . registerTelemetryHook ( ) ;
10381080 }
10391081 } catch ( error ) {
10401082 // ignore error
10411083 }
10421084
10431085 // set some toolpath to env
1044- exportEnvToSysPath ( ) ;
1086+ exportEnvToSysPath ( context ) ;
10451087
10461088 // init status bar
10471089 {
0 commit comments