Skip to content

Commit dea79fe

Browse files
committed
Avoid hard-coding .cs extension
1 parent 09bec45 commit dea79fe

4 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/Package/Update/PackageUpdateArgs.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,10 @@ internal record PackageUpdateArgs
2424
/// Path to a file with the XML content of the project (used for virtual projects).
2525
/// </summary>
2626
public string? ProjectContentFile { get; init; }
27+
28+
/// <summary>
29+
/// For virtual projects (when <see cref="ProjectContentFile"/> is set), this is the original path to the entry-point file.
30+
/// </summary>
31+
public string? OriginalProject { get; init; }
2732
}
2833
}

src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/Package/Update/PackageUpdateCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ internal static void Register(Command packageCommand, Option<bool> interactiveOp
6464
bool vulnerable = args.GetValue(vulnerableOption);
6565

6666
var projectPath = project?.FullName ?? Environment.CurrentDirectory;
67+
var originalProjectPath = projectPath;
6768
var projectContentFile = args.GetValue(projectContentFileOption)?.FullName;
6869
projectPath = MSBuildAPIUtility.ChangeProjectPath(projectPath, projectContentFile);
6970

@@ -75,6 +76,7 @@ internal static void Register(Command packageCommand, Option<bool> interactiveOp
7576
LogLevel = logLevel,
7677
Vulnerable = vulnerable,
7778
ProjectContentFile = projectContentFile,
79+
OriginalProject = originalProjectPath,
7880
};
7981

8082
return await action(commandArgs, cancellationToken);

src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/Package/Update/PackageUpdateCommandRunner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ internal static async Task<int> Run(PackageUpdateArgs args, ILoggerWithColor log
5656

5757
// 1. Get DGSpec for project/solution
5858
logger.LogVerbose(Strings.PackageUpdate_LoadingDGSpec);
59-
var dgSpec = packageUpdateIO.GetDependencyGraphSpec(args.Project, args.ProjectContentFile);
59+
var dgSpec = packageUpdateIO.GetDependencyGraphSpec(args.OriginalProject ?? args.Project, args.ProjectContentFile);
6060

6161
if (dgSpec is null || dgSpec.Restore is null || dgSpec.Restore.Count == 0)
6262
{

src/NuGet.Core/NuGet.CommandLine.XPlat/Commands/Package/Update/PackageUpdateIO.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ bool RunMsbuildTarget(string project, string tempFile, string? projectContentFil
9090
ProcessStartInfo processStartInfo = new ProcessStartInfo(dotnetPath)
9191
{
9292
Arguments = $"build " +
93-
$"\"{(projectContentFile is null ? project : Path.ChangeExtension(project, ".cs"))}\" " +
93+
$"\"{project}\" " +
9494
$"--no-restore " +
9595
$"-target:GenerateRestoreGraphFile " +
9696
$"-property:RestoreGraphOutputPath=\"{tempFile}\" " +

0 commit comments

Comments
 (0)