Skip to content

Handle versioned #:sdk being first #49807

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jjonescz
Copy link
Member

Fixes #49797.

@jjonescz jjonescz added the Area-run-file Items related to the "dotnet run <file>" effort label Jul 16, 2025
@jjonescz jjonescz marked this pull request as ready for review July 16, 2025 14:19
@jjonescz jjonescz requested review from Copilot and a team July 16, 2025 14:19
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 issue 49797 by ensuring versioned #:sdk directives at the top of a C# script are handled correctly for both dotnet run and dotnet project convert.

  • Added SdkReference_VersionedSdkFirst test in RunFileTests.cs
  • Added Directives_VersionedSdkFirst test in DotnetProjectConvertTests.cs
  • Updated VirtualProjectBuildingCommand to split SDK name and version, adjust imports, and remove the old ToSlashDelimitedString method

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
test/dotnet.Tests/CommandTests/Run/RunFileTests.cs New fact validating build when a versioned #:sdk is first
test/dotnet.Tests/CommandTests/Project/Convert/...ConvertTests.cs New fact validating conversion when a versioned #:sdk is first
src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs Logic to correctly handle first versioned SDK directive and adjust import statements

@jjonescz
Copy link
Member Author

@RikkiGibson @jaredpar please review a small but important bugfix, thanks

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 app.cs #:sdk directive pinned version results in The SDK 'Sdk/Version' specified could not be found.
2 participants