@@ -477,7 +477,8 @@ ProjectRootElement CreateProjectRootElement(ProjectCollection projectCollection)
477477 _directives ,
478478 isVirtualProject : true ,
479479 targetFilePath : EntryPointFileFullPath ,
480- artifactsPath : GetArtifactsPath ( ) ) ;
480+ artifactsPath : GetArtifactsPath ( ) ,
481+ includeRuntimeConfigInformation : BuildTarget != "Publish" ) ;
481482 var projectFileText = projectFileWriter . ToString ( ) ;
482483
483484 using var reader = new StringReader ( projectFileText ) ;
@@ -511,7 +512,8 @@ public static void WriteProjectFile(
511512 ImmutableArray < CSharpDirective > directives ,
512513 bool isVirtualProject ,
513514 string ? targetFilePath = null ,
514- string ? artifactsPath = null )
515+ string ? artifactsPath = null ,
516+ bool includeRuntimeConfigInformation = true )
515517 {
516518 int processedDirectives = 0 ;
517519
@@ -691,14 +693,17 @@ public static void WriteProjectFile(
691693
692694 """ ) ;
693695
694- var targetDirectory = Path . GetDirectoryName ( targetFilePath ) ?? "" ;
695- writer . WriteLine ( $ """
696+ if ( includeRuntimeConfigInformation )
697+ {
698+ var targetDirectory = Path . GetDirectoryName ( targetFilePath ) ?? "" ;
699+ writer . WriteLine ( $ """
696700 <ItemGroup>
697701 <RuntimeHostConfigurationOption Include="EntryPointFilePath" Value="{ EscapeValue ( targetFilePath ) } " />
698702 <RuntimeHostConfigurationOption Include="EntryPointFileDirectoryPath" Value="{ EscapeValue ( targetDirectory ) } " />
699703 </ItemGroup>
700704
701705 """ ) ;
706+ }
702707
703708 foreach ( var sdk in sdkDirectives )
704709 {
0 commit comments