@@ -159,6 +159,30 @@ public void Hostfxr_resolve_sdk2_NoGlobalJson_DisallowPrerelease()
159159                . And . HaveStdOutContaining ( $ "{ api }  data:[{ expectedData } ]") ; 
160160        } 
161161
162+         [ Theory ] 
163+         [ InlineData ( true ) ] 
164+         [ InlineData ( false ) ] 
165+         public  void  Hostfxr_resolve_sdk2_NoGlobalJson_NoWriteToStdResolvesTheSame ( bool  do_not_print_errors ) 
166+         { 
167+             // With no global.json and disallowing previews, pick latest non-preview 
168+ 
169+             var  f  =  sharedTestState . SdkAndFrameworkFixture ; 
170+             string  expectedData  =  string . Join ( ';' ,  new [ ] 
171+             { 
172+                 ( "resolved_sdk_dir" ,  Path . Combine ( f . LocalSdkDir ,  "1.2.300" ) ) , 
173+                 ( "global_json_state" ,  "not_found" ) , 
174+             } ) ; 
175+ 
176+             string  api  =  ApiNames . hostfxr_resolve_sdk2 ; 
177+             string  flags  =  do_not_print_errors  ?  "disallow_prerelease,do_not_print_errors"  :  "disallow_prerelease" ; 
178+             TestContext . BuiltDotNet . Exec ( sharedTestState . HostApiInvokerApp . AppDll ,  api ,  f . ExeDir ,  NoGlobalJson ,  flags ) 
179+                 . EnableTracingAndCaptureOutputs ( ) 
180+                 . Execute ( ) 
181+                 . Should ( ) . Pass ( ) 
182+                 . And . ReturnStatusCode ( api ,  Constants . ErrorCode . Success ) 
183+                 . And . HaveStdOutContaining ( $ "{ api }  data:[{ expectedData } ]") ; 
184+         } 
185+ 
162186        [ Fact ] 
163187        public  void  Hostfxr_resolve_sdk2_GlobalJson_DisallowPrerelease ( ) 
164188        { 
@@ -301,6 +325,32 @@ public void Hostfxr_resolve_sdk2_GlobalJson_InvalidDataNoFallback()
301325            } 
302326        } 
303327
328+         [ Theory ] 
329+         [ InlineData ( false ) ] 
330+         [ InlineData ( true ) ] 
331+         public  void  Hostfxr_resolve_sdk2_FailsToResolve_NoWriteToStd ( bool  do_not_print_errors ) 
332+         { 
333+             var  f  =  sharedTestState . SdkAndFrameworkFixture ; 
334+             string  api  =  ApiNames . hostfxr_resolve_sdk2 ; 
335+             using  TestArtifact  workingDir  =  TestArtifact . Create ( nameof ( Hostfxr_resolve_sdk2_FailsToResolve_NoWriteToStd ) ) ; 
336+ 
337+             string  invalidVersion  =  "1.2.0" ;  // feature band < 1 triggers __invalid_data_no_fallback 
338+             GlobalJson . CreateWithVersion ( workingDir . Location ,  invalidVersion ) ; 
339+ 
340+             var  result  =  TestContext . BuiltDotNet . Exec ( sharedTestState . HostApiInvokerApp . AppDll ,  api ,  f . ExeDir ,  workingDir . Location ,  do_not_print_errors  ?  "do_not_print_errors"  :  "0" ) 
341+                 . CaptureStdOut ( ) 
342+                 . CaptureStdErr ( ) 
343+                 . Execute ( ) ; 
344+ 
345+             result . Should ( ) . Pass ( ) 
346+                 . And . ReturnStatusCode ( api ,  Constants . ErrorCode . SdkResolveFailure ) ; 
347+ 
348+             if  ( do_not_print_errors ) 
349+                 result . StdErr . Should ( ) . BeEmpty ( ) ; 
350+             else 
351+                 result . StdErr . Should ( ) . Contain ( "A compatible .NET SDK was not found." ) ; 
352+         } 
353+ 
304354        [ Fact ] 
305355        public  void  Hostfxr_corehost_set_error_writer_test ( ) 
306356        { 
0 commit comments