@@ -477,7 +477,8 @@ ProjectRootElement CreateProjectRootElement(ProjectCollection projectCollection)
477
477
_directives ,
478
478
isVirtualProject : true ,
479
479
targetFilePath : EntryPointFileFullPath ,
480
- artifactsPath : GetArtifactsPath ( ) ) ;
480
+ artifactsPath : GetArtifactsPath ( ) ,
481
+ includeRuntimeConfigInformation : BuildTarget != "Publish" ) ;
481
482
var projectFileText = projectFileWriter . ToString ( ) ;
482
483
483
484
using var reader = new StringReader ( projectFileText ) ;
@@ -511,7 +512,8 @@ public static void WriteProjectFile(
511
512
ImmutableArray < CSharpDirective > directives ,
512
513
bool isVirtualProject ,
513
514
string ? targetFilePath = null ,
514
- string ? artifactsPath = null )
515
+ string ? artifactsPath = null ,
516
+ bool includeRuntimeConfigInformation = true )
515
517
{
516
518
int processedDirectives = 0 ;
517
519
@@ -691,14 +693,17 @@ public static void WriteProjectFile(
691
693
692
694
""" ) ;
693
695
694
- var targetDirectory = Path . GetDirectoryName ( targetFilePath ) ?? "" ;
695
- writer . WriteLine ( $ """
696
+ if ( includeRuntimeConfigInformation )
697
+ {
698
+ var targetDirectory = Path . GetDirectoryName ( targetFilePath ) ?? "" ;
699
+ writer . WriteLine ( $ """
696
700
<ItemGroup>
697
701
<RuntimeHostConfigurationOption Include="EntryPointFilePath" Value="{ EscapeValue ( targetFilePath ) } " />
698
702
<RuntimeHostConfigurationOption Include="EntryPointFileDirectoryPath" Value="{ EscapeValue ( targetDirectory ) } " />
699
703
</ItemGroup>
700
704
701
705
""" ) ;
706
+ }
702
707
703
708
foreach ( var sdk in sdkDirectives )
704
709
{
0 commit comments