@@ -77,6 +77,62 @@ public void NativeAot_hw_runs_with_no_warnings_when_PublishAot_is_enabled(string
7777 . And . HaveStdOutContaining ( "Hello World" ) ;
7878 }
7979
80+ [ RequiresMSBuildVersionTheory ( "17.12.0" , Skip = "https://github.com/dotnet/sdk/issues/46006" ) ]
81+ [ MemberData ( nameof ( Net7Plus ) , MemberType = typeof ( PublishTestUtils ) ) ]
82+ public void NativeAot_app_publishes_with_space_in_path ( string targetFramework )
83+ {
84+ if ( targetFramework == "net7.0" && RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) )
85+ {
86+ // 7.0 is not supported on Mac
87+ return ;
88+ }
89+
90+ var projectName = "HelloWorldNativeAotApp" ;
91+
92+ var testProject = CreateHelloWorldTestProject ( targetFramework , projectName , true ) ;
93+ testProject . RecordProperties ( "NETCoreSdkPortableRuntimeIdentifier" ) ;
94+ testProject . AdditionalProperties [ "PublishAot" ] = "true" ;
95+ // Linux symbol files are embedded and require additional steps to be stripped to a separate file
96+ // assumes /bin (or /usr/bin) are in the PATH
97+ if ( ! RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
98+ {
99+ testProject . AdditionalProperties [ "StripSymbols" ] = "true" ;
100+ }
101+ // Use an identifier with a space to create a path with a space
102+ var testAsset = _testAssetsManager . CreateTestProject ( testProject , identifier : "with space" ) ;
103+
104+ var publishCommand = new PublishCommand ( Log , Path . Combine ( testAsset . TestRoot , testProject . Name ) ) ;
105+ publishCommand
106+ . Execute ( $ "/p:UseCurrentRuntimeIdentifier=true", "/p:SelfContained=true" , "/p:CheckEolTargetFramework=false" )
107+ . Should ( ) . Pass ( )
108+ . And . NotHaveStdOutContaining ( "IL2026" )
109+ . And . NotHaveStdErrContaining ( "NETSDK1179" )
110+ . And . NotHaveStdErrContaining ( "warning" )
111+ . And . NotHaveStdOutContaining ( "warning" ) ;
112+
113+ var buildProperties = testProject . GetPropertyValues ( testAsset . TestRoot , targetFramework ) ;
114+ var rid = buildProperties [ "NETCoreSdkPortableRuntimeIdentifier" ] ;
115+ var publishDirectory = publishCommand . GetOutputDirectory ( targetFramework : targetFramework , runtimeIdentifier : rid ) . FullName ;
116+ var publishedExe = Path . Combine ( publishDirectory , $ "{ testProject . Name } { Constants . ExeSuffix } ") ;
117+
118+ // Verify the path contains a space
119+ testAsset . TestRoot . Should ( ) . Contain ( " " , "Test should run with a space in the path" ) ;
120+
121+ // The exe should exist and should be native
122+ File . Exists ( publishedExe ) . Should ( ) . BeTrue ( ) ;
123+ DoSymbolsExist ( publishDirectory , testProject . Name ) . Should ( ) . BeTrue ( $ "{ publishDirectory } should contain { testProject . Name } symbol") ;
124+ IsNativeImage ( publishedExe ) . Should ( ) . BeTrue ( ) ;
125+
126+ bool useRuntimePackLayout = targetFramework is not ( "net7.0" or "net8.0" or "net9.0" ) ;
127+
128+ GetKnownILCompilerPackVersion ( testAsset , targetFramework , out string expectedVersion ) ;
129+ CheckIlcVersions ( testAsset , targetFramework , rid , expectedVersion , useRuntimePackLayout ) ;
130+
131+ var command = new RunExeCommand ( Log , publishedExe )
132+ . Execute ( ) . Should ( ) . Pass ( )
133+ . And . HaveStdOutContaining ( "Hello World" ) ;
134+ }
135+
80136 [ RequiresMSBuildVersionTheory ( "17.12.0" ) ]
81137 [ MemberData ( nameof ( Net7Plus ) , MemberType = typeof ( PublishTestUtils ) ) ]
82138 public void NativeAot_hw_runs_with_no_warnings_when_PublishAot_is_false ( string targetFramework )
0 commit comments