@@ -36,11 +36,11 @@ static async Task<int> Main(string[] args)
3636 ConfigureAppConfiguration ( configBuilder ) ;
3737 var config = configBuilder . Build ( ) ;
3838
39- var authSettings = config . GetRequiredSection ( Constants . AuthenticationSection ) . Get < AuthenticationOptions > ( ) ;
40- var authServiceFactory = new AuthenticationServiceFactory ( ) ;
39+ var authSettings = config . GetSection ( Constants . AuthenticationSection ) . Get < AuthenticationOptions > ( ) ;
40+ var authServiceFactory = new AuthenticationServiceFactory ( new PathUtility ( ) ) ;
4141 var authStrategy = AuthenticationStrategy . DeviceCode ;
4242
43- var credential = await authServiceFactory . GetTokenCredentialAsync ( authStrategy , authSettings . TenantId , authSettings . ClientId ) ;
43+ var credential = await authServiceFactory . GetTokenCredentialAsync ( authStrategy , authSettings ? . TenantId , authSettings ? . ClientId ) ;
4444 var authProvider = new AzureIdentityAuthenticationProvider ( credential ) ;
4545 var defaultHandlers = KiotaClientFactory . CreateDefaultHandlers ( ) ;
4646
@@ -90,9 +90,7 @@ static IHostBuilder CreateHostBuilder(string[] args) =>
9090 Host . CreateDefaultBuilder ( ) . ConfigureHostConfiguration ( ( configHost ) => {
9191 configHost . SetBasePath ( Directory . GetCurrentDirectory ( ) ) ;
9292 } ) . ConfigureAppConfiguration ( ( ctx , config ) => {
93- var env = ctx . HostingEnvironment ;
9493 ConfigureAppConfiguration ( config ) ;
95- config . AddJsonFile ( $ "app-settings.{ env . EnvironmentName } .json", optional : true , true ) ;
9694 } ) . ConfigureServices ( ( ctx , services ) => {
9795 var authSection = ctx . Configuration . GetSection ( Constants . AuthenticationSection ) ;
9896 services . Configure < AuthenticationOptions > ( authSection ) ;
@@ -101,10 +99,10 @@ static IHostBuilder CreateHostBuilder(string[] args) =>
10199
102100 static void ConfigureAppConfiguration ( IConfigurationBuilder builder ) {
103101 builder . Sources . Clear ( ) ;
104- builder . AddJsonFile ( "app-settings.json" , optional : true ) ;
105- var home = new PathUtility ( ) . GetUserHomeDirectory ( ) ;
106- var userConfigPath = Path . Combine ( home , Constants . ApplicationDataDirectory , "settings.json" ) ;
107- builder . AddJsonFile ( userConfigPath ) ;
102+ builder . AddJsonFile ( "app-settings.json" , optional : false ) ;
103+ var dataDir = new PathUtility ( ) . GetApplicationDataDirectory ( ) ;
104+ var userConfigPath = Path . Combine ( dataDir , "settings.json" ) ;
105+ builder . AddJsonFile ( userConfigPath , optional : true ) ;
108106 builder . AddEnvironmentVariables ( prefix : "MGC_" ) ;
109107 }
110108 }
0 commit comments