Skip to content

Commit 7e68568

Browse files
tmatRikkiGibson
andauthored
Virtual project builder (#52030)
Co-authored-by: Rikki Gibson <[email protected]>
1 parent 554d40c commit 7e68568

File tree

34 files changed

+782
-678
lines changed

34 files changed

+782
-678
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,4 +382,12 @@ public void ApplyPropertiesToRestore()
382382
RestoreGlobalProperties = new(newdict);
383383
}
384384
}
385+
386+
internal string[]? GetResolvedTargets()
387+
=> this switch
388+
{
389+
{ RequestedTargets: null or { Length: 0 } } => GetTargetResult,
390+
{ GetTargetResult: null or { Length: 0 } } => RequestedTargets,
391+
_ => [.. RequestedTargets.Union(GetTargetResult, StringComparer.OrdinalIgnoreCase)]
392+
};
385393
}

src/Cli/Microsoft.TemplateEngine.Cli/Microsoft.TemplateEngine.Cli.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
</ItemGroup>
2121

2222
<ItemGroup>
23-
<ProjectReference Include="../Microsoft.DotNet.Cli.CommandLine/Microsoft.DotNet.Cli.CommandLine.csproj" GlobalPropertiesToRemove="PublishDir" />
24-
<ProjectReference Include="../Microsoft.DotNet.Cli.Utils/Microsoft.DotNet.Cli.Utils.csproj" GlobalPropertiesToRemove="PublishDir" />
25-
<ProjectReference Include="../Microsoft.DotNet.Configurer/Microsoft.DotNet.Configurer.csproj" GlobalPropertiesToRemove="PublishDir" />
23+
<ProjectReference Include="..\Microsoft.DotNet.Cli.CommandLine\Microsoft.DotNet.Cli.CommandLine.csproj" GlobalPropertiesToRemove="PublishDir" />
24+
<ProjectReference Include="..\Microsoft.DotNet.Cli.Utils\Microsoft.DotNet.Cli.Utils.csproj" GlobalPropertiesToRemove="PublishDir" />
25+
<ProjectReference Include="..\Microsoft.DotNet.Configurer\Microsoft.DotNet.Configurer.csproj" GlobalPropertiesToRemove="PublishDir" />
26+
<ProjectReference Include="..\..\Microsoft.DotNet.ProjectTools\Microsoft.DotNet.ProjectTools.csproj" />
2627
</ItemGroup>
2728

2829
<ItemGroup>

src/Cli/Microsoft.TemplateEngine.Cli/TelemetryHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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 Microsoft.DotNet.Cli.Utils;
4+
using Microsoft.DotNet.Utilities;
55
using Microsoft.TemplateEngine.Abstractions;
66
using Microsoft.TemplateEngine.Utils;
77

src/Cli/Microsoft.TemplateEngine.Cli/TemplateInvoker.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Text.RegularExpressions;
55
using Microsoft.DotNet.Cli.Utils;
66
using Microsoft.DotNet.Cli.Utils.Extensions;
7+
using Microsoft.DotNet.Utilities;
78
using Microsoft.TemplateEngine.Abstractions;
89
using Microsoft.TemplateEngine.Abstractions.TemplatePackage;
910
using Microsoft.TemplateEngine.Cli.Commands;

src/Cli/dotnet/CommandFactory/CommandResolution/CompositeCommandResolver.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#nullable disable
55

66
using Microsoft.DotNet.Cli.Utils;
7+
using Microsoft.DotNet.Utilities;
78

89
namespace Microsoft.DotNet.Cli.CommandFactory.CommandResolution;
910

src/Cli/dotnet/Commands/Build/BuildCommand.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,14 @@ public static CommandBase FromParseResult(ParseResult parseResult, string? msbui
3030
return CommandFactory.CreateVirtualOrPhysicalCommand(
3131
BuildCommandParser.GetCommand(),
3232
BuildCommandDefinition.SlnOrProjectOrFileArgument,
33-
(msbuildArgs, appFilePath) => new VirtualProjectBuildingCommand(
33+
configureVirtualCommand: (msbuildArgs, appFilePath) => new VirtualProjectBuildingCommand(
3434
entryPointFileFullPath: Path.GetFullPath(appFilePath),
35-
msbuildArgs: msbuildArgs
36-
)
35+
msbuildArgs: msbuildArgs)
3736
{
3837
NoRestore = noRestore,
3938
NoCache = true,
4039
},
41-
(msbuildArgs, msbuildPath) => new RestoringCommand(
40+
createPhysicalCommand: (msbuildArgs, msbuildPath) => new RestoringCommand(
4241
msbuildArgs: msbuildArgs.CloneWithAdditionalArgs("-consoleloggerparameters:Summary"),
4342
noRestore: noRestore,
4443
msbuildPath: msbuildPath

src/Cli/dotnet/Commands/Clean/CleanCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public static CommandBase FromParseResult(ParseResult result, string? msbuildPat
2424
CleanCommandParser.GetCommand(),
2525
CleanCommandDefinition.SlnOrProjectOrFileArgument,
2626
static (msbuildArgs, appFilePath) => new VirtualProjectBuildingCommand(
27-
entryPointFileFullPath: appFilePath,
28-
msbuildArgs: msbuildArgs)
27+
entryPointFileFullPath: appFilePath,
28+
msbuildArgs: msbuildArgs)
2929
{
3030
NoBuild = false,
3131
NoRestore = true,

src/Cli/dotnet/Commands/Clean/FileBasedAppArtifacts/CleanFileBasedAppArtifactsCommand.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Microsoft.DotNet.Cli.Commands.Run;
88
using Microsoft.DotNet.Cli.Utils;
99
using Microsoft.DotNet.Cli.Utils.Extensions;
10+
using Microsoft.DotNet.ProjectTools;
1011

1112
namespace Microsoft.DotNet.Cli.Commands.Clean.FileBasedAppArtifacts;
1213

@@ -60,7 +61,7 @@ public override int Execute()
6061

6162
private IEnumerable<DirectoryInfo> GetFoldersToRemove()
6263
{
63-
var directory = new DirectoryInfo(VirtualProjectBuildingCommand.GetTempSubdirectory());
64+
var directory = new DirectoryInfo(VirtualProjectBuilder.GetTempSubdirectory());
6465

6566
if (!directory.Exists)
6667
{
@@ -84,7 +85,7 @@ private IEnumerable<DirectoryInfo> GetFoldersToRemove()
8485

8586
private static FileInfo GetMetadataFile()
8687
{
87-
return new FileInfo(VirtualProjectBuildingCommand.GetTempSubpath(RunFileArtifactsMetadata.FilePath));
88+
return new FileInfo(VirtualProjectBuilder.GetTempSubpath(RunFileArtifactsMetadata.FilePath));
8889
}
8990

9091
private FileStream? OpenMetadataFile()

src/Cli/dotnet/Commands/CommandFactory.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Microsoft.DotNet.Cli.CommandLine;
66
using Microsoft.DotNet.Cli.Commands.Run;
77
using Microsoft.DotNet.Cli.Utils;
8+
using Microsoft.DotNet.ProjectTools;
89

910
namespace Microsoft.DotNet.Cli.Commands;
1011

@@ -23,7 +24,7 @@ internal static CommandBase CreateVirtualOrPhysicalCommand(
2324
var args = parseResult.GetValue(catchAllUserInputArgument) ?? [];
2425
LoggerUtility.SeparateBinLogArguments(args, out var binLogArgs, out var nonBinLogArgs);
2526
var forwardedArgs = parseResult.OptionValuesToBeForwarded(command);
26-
if (nonBinLogArgs is [{ } arg] && VirtualProjectBuildingCommand.IsValidEntryPointPath(arg))
27+
if (nonBinLogArgs is [{ } arg] && VirtualProjectBuilder.IsValidEntryPointPath(arg))
2728
{
2829
var msbuildArgs = MSBuildArgs.AnalyzeMSBuildArguments([.. forwardedArgs, .. binLogArgs],
2930
[

src/Cli/dotnet/Commands/Hidden/InternalReportInstallSuccess/InternalReportInstallSuccessCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Microsoft.DotNet.Cli.Telemetry;
99
using Microsoft.DotNet.Cli.Utils;
1010
using Microsoft.DotNet.Configurer;
11+
using Microsoft.DotNet.Utilities;
1112

1213
namespace Microsoft.DotNet.Cli.Commands.Hidden.InternalReportInstallSuccess;
1314

0 commit comments

Comments
 (0)