Skip to content

Commit 27ae645

Browse files
authored
Don't include runtime config info during publish (#49394)
1 parent 0eb4fbc commit 27ae645

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)