@@ -14,6 +14,7 @@ sealed class DevProxyCommand : RootCommand
1414 private readonly IProxyConfiguration _proxyConfiguration ;
1515 private readonly ISet < UrlToWatch > _urlsToWatch ;
1616 private readonly UpdateNotification _updateNotification ;
17+ private readonly IConfiguration _configuration ;
1718 private WebApplication ? _app ;
1819
1920 internal const string PortOptionName = "--port" ;
@@ -59,13 +60,15 @@ public DevProxyCommand(
5960 IProxyConfiguration proxyConfiguration ,
6061 IServiceProvider serviceProvider ,
6162 UpdateNotification updateNotification ,
63+ IConfiguration configuration ,
6264 ILogger < DevProxyCommand > logger ) : base ( "Start Dev Proxy" )
6365 {
6466 _serviceProvider = serviceProvider ;
6567 _plugins = plugins ;
6668 _urlsToWatch = urlsToWatch ;
6769 _proxyConfiguration = proxyConfiguration ;
6870 _updateNotification = updateNotification ;
71+ _configuration = configuration ;
6972 _logger = logger ;
7073
7174 ConfigureCommand ( ) ;
@@ -84,6 +87,11 @@ private async Task<int> InvokeAsync(ParseResult parseResult, CancellationToken c
8487 {
8588 throw new InvalidOperationException ( "WebApplication instance is not set. Please provide it when invoking the command." ) ;
8689 }
90+ if ( ( _configuration as IConfigurationRoot ) ? . Providers . Any ( p => p is FileConfigurationProvider ) != true )
91+ {
92+ _logger . LogError ( "No configuration file found. Please create a devproxyrc.json file in the current directory." ) ;
93+ return 1 ;
94+ }
8795 if ( ! _plugins . Any ( ) )
8896 {
8997 _logger . LogError ( "You haven't configured any plugins. Please add plugins to your configuration file. Dev Proxy will exit." ) ;
0 commit comments