Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

jjonescz
Copy link
Member

Fixes #50832.

@jjonescz jjonescz added the Area-run-file Items related to the "dotnet run <file>" effort label Sep 16, 2025
Copy link
Contributor

This PR is targeting main, which is now for .NET 11-facing work. If you intended to target .NET 10, either retarget this PR to release/10.0.1xx or make sure you backport the change to release/10.0.1xx after merging. See #50394 for more details.

@jjonescz jjonescz changed the base branch from main to release/10.0.1xx September 16, 2025 08:42
@jjonescz jjonescz marked this pull request as ready for review September 16, 2025 10:37
@jjonescz jjonescz requested review from a team and Copilot September 16, 2025 10:38
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes project reference path handling during file-based application conversion by ensuring relative paths are properly adjusted when the output directory differs from the source directory.

  • Adds logic to update relative project reference paths to be relative to the output directory instead of source directory
  • Preserves absolute paths as-is while only modifying relative paths during conversion
  • Adds comprehensive test coverage for various relative and absolute path scenarios

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
test/dotnet.Tests/CommandTests/Project/Convert/DotnetProjectConvertTests.cs Adds test cases covering relative and absolute project reference path conversion scenarios
src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs Adds WithName method to Project class and preserves absolute paths during directive processing
src/Cli/dotnet/Commands/Project/Convert/ProjectConvertCommand.cs Implements UpdateDirectives method to adjust relative project reference paths for the target directory

[Theory] // https://github.com/dotnet/sdk/issues/50832
[InlineData("File", "Lib", "../Lib", "Project", "../Lib/lib.csproj")]
[InlineData(".", "Lib", "./Lib", "Project", "../Lib/lib.csproj")]
[InlineData("File", "Lib", "../Lib", "File/Project", "../../Lib/lib.csproj")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider also testing a case where the original path has redundant ..s in it, such as Lib/../Lib, I would expect such paths to get normalized (be treated as equivalent to just Lib).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider also testing both windows and unix path separators.

@jjonescz
Copy link
Member Author

@MiYanni for a review, thanks

@baronfel baronfel merged commit 0fc992c into dotnet:release/10.0.1xx Sep 22, 2025
27 checks passed
@jjonescz jjonescz deleted the sprint-convert-project-ref branch September 22, 2025 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-run-file Items related to the "dotnet run <file>" effort
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dotnet project convert should fix up relative paths in #:project references
4 participants