1515using System . Runtime . CompilerServices ;
1616using System ;
1717using System . Runtime . InteropServices ;
18+ using Microsoft . DotNet . PlatformAbstractions ;
1819
1920namespace Microsoft . NET . ToolPack . Tests
2021{
@@ -125,10 +126,10 @@ public void It_contains_runtimeconfig_for_each_tfm(bool multiTarget)
125126 }
126127 }
127128
128- [ Theory ]
129+ [ WindowsOnlyTheory ]
129130 [ InlineData ( true ) ]
130131 [ InlineData ( false ) ]
131- public void It_does_not_contain_apphost_exe ( bool multiTarget )
132+ public void Given_Windows_It_does_not_contain_apphost_exe_but_RunCommand_is_apphost_exe ( bool multiTarget )
132133 {
133134 _targetFrameworkOrFrameworks = "netcoreapp3.0" ;
134135
@@ -140,7 +141,7 @@ public void It_does_not_contain_apphost_exe(bool multiTarget)
140141
141142 foreach ( NuGet . Frameworks . NuGetFramework framework in supportedFrameworks )
142143 {
143- var extension = RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ? ".exe" : " ";
144+ var extension = ".exe" ;
144145 var allItems = nupkgReader . GetToolItems ( ) . SelectMany ( i => i . Items ) . ToList ( ) ;
145146 allItems . Should ( ) . NotContain ( $ "tools/{ framework . GetShortFolderName ( ) } /any/consoledemo{ extension } ") ;
146147 }
@@ -154,8 +155,45 @@ public void It_does_not_contain_apphost_exe(bool multiTarget)
154155 GetValuesCommand . ValueType . Property ) ;
155156
156157 getValuesCommand . Execute ( ) ;
157- Path . GetExtension ( getValuesCommand . GetValues ( ) . Single ( ) )
158- . Should ( ) . NotBe ( ".exe" , "Repro https://github.com/dotnet/cli/issues/11299" ) ;
158+ string runCommandPath = getValuesCommand . GetValues ( ) . Single ( ) ;
159+ Path . GetExtension ( runCommandPath )
160+ . Should ( ) . Be ( ".exe" ) ;
161+ File . Exists ( runCommandPath ) . Should ( )
162+ . BeTrue ( "run command should be apphost exe for WinExe to debug. But it will not be packed" ) ;
163+ }
164+
165+ [ PlatformSpecificTheory ( Platform . Linux , Platform . Darwin , Platform . FreeBSD ) ]
166+ [ InlineData ( true ) ]
167+ [ InlineData ( false ) ]
168+ public void Given_nonwindows_It_does_not_contain_apphost_and_RunCommand_is_not_apphost ( bool multiTarget )
169+ {
170+ _targetFrameworkOrFrameworks = "netcoreapp3.0" ;
171+
172+ var nugetPackage = SetupNuGetPackage ( multiTarget ) ;
173+ using ( var nupkgReader = new PackageArchiveReader ( nugetPackage ) )
174+ {
175+ IEnumerable < NuGet . Frameworks . NuGetFramework > supportedFrameworks = nupkgReader . GetSupportedFrameworks ( ) ;
176+ supportedFrameworks . Should ( ) . NotBeEmpty ( ) ;
177+
178+ foreach ( NuGet . Frameworks . NuGetFramework framework in supportedFrameworks )
179+ {
180+ var allItems = nupkgReader . GetToolItems ( ) . SelectMany ( i => i . Items ) . ToList ( ) ;
181+ allItems . Should ( ) . NotContain ( $ "tools/{ framework . GetShortFolderName ( ) } /any/consoledemo") ;
182+ }
183+ }
184+
185+ var getValuesCommand = new GetValuesCommand (
186+ Log ,
187+ _testRoot ,
188+ _targetFrameworkOrFrameworks ,
189+ "RunCommand" ,
190+ GetValuesCommand . ValueType . Property ) ;
191+
192+ getValuesCommand . Execute ( ) ;
193+ string runCommandPath = getValuesCommand . GetValues ( ) . Single ( ) ;
194+ Path . GetExtension ( runCommandPath )
195+ . Should ( ) . NotBe ( ".exe" ) ;
196+ File . Exists ( runCommandPath ) . Should ( ) . BeTrue ( "non Windows does not generate apphost by default" ) ;
159197 }
160198
161199 [ Theory ]
0 commit comments