Skip to content

Commit 806e650

Browse files
baronfelCopilot
andauthored
ensure that Content items are available during restore to un-break Razor (#49783)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 1177acc commit 806e650

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/Cli/Microsoft.DotNet.Cli.Utils/Constants.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ public static class Constants
1919

2020
public static readonly string MSBUILD_EXE_PATH = nameof(MSBUILD_EXE_PATH);
2121
public static readonly string MSBuildExtensionsPath = nameof(MSBuildExtensionsPath);
22+
2223
public static readonly string EnableDefaultItems = nameof(EnableDefaultItems);
24+
public static readonly string EnableDefaultContentItems = nameof(EnableDefaultContentItems);
2325
public static readonly string EnableDefaultCompileItems = nameof(EnableDefaultCompileItems);
2426
public static readonly string EnableDefaultEmbeddedResourceItems = nameof(EnableDefaultEmbeddedResourceItems);
2527
public static readonly string EnableDefaultNoneItems = nameof(EnableDefaultNoneItems);

src/Cli/dotnet/Commands/Restore/RestoringCommand.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System.Collections.Frozen;
54
using System.Collections.ObjectModel;
65
using Microsoft.DotNet.Cli.Commands.MSBuild;
76
using Microsoft.DotNet.Cli.Commands.Workload.Install;
@@ -12,7 +11,6 @@ namespace Microsoft.DotNet.Cli.Commands.Restore;
1211

1312
public class RestoringCommand : MSBuildForwardingApp
1413
{
15-
1614
/// <summary>
1715
/// This dictionary contains properties that are set to disable the default items
1816
/// that are added to the project by default. These Item types are not needed
@@ -22,7 +20,9 @@ public class RestoringCommand : MSBuildForwardingApp
2220
public static ReadOnlyDictionary<string, string> RestoreOptimizationProperties =>
2321
new(new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
2422
{
25-
{ Constants.EnableDefaultItems, "false" },
23+
// note that we do not disable all default items - Razor at least needs Content
24+
// in order to do implicit PackageReferences if Razor files are present
25+
{ Constants.EnableDefaultCompileItems, "false" },
2626
{ Constants.EnableDefaultEmbeddedResourceItems, "false" },
2727
{ Constants.EnableDefaultNoneItems, "false" },
2828
});

0 commit comments

Comments
 (0)