Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 11, 2025

Fixes #36142

Description
The dotnet ef migrations bundle command was failing on Linux because the path construction logic didn't properly normalize directory separators. MSBuild returned OutputPath containing backslashes (e.g., bin\Debug/net10.0) which, when combined with forward-slash project paths on Linux, resulted in mixed separator paths like /home/user/project/bin\Debug/net10.0/App.deps.json, causing the dotnet exec command to fail with "The specified deps.json [path] does not exist".

Customer impact
Customers using EF Core tools on Linux could not create migration bundles using dotnet ef. The workaround would be to call into the underlying ef.dll manually with the correct path, but this is a poor experience.

How found
7 customer reports

Regression
Yes, from EF 9. Introduced in #34574

Testing
Manually verified by creating a test EF project and successfully executing dotnet-ef migrations bundle on Linux

Risk
Low. The change is a simple path normalization.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] "dotnet-ef migrations bundle" command broken on Linux with .NET 10 Fix dotnet-ef migrations bundle command on Linux with mixed path separators Sep 11, 2025
@Copilot Copilot AI requested a review from AndriySvyryd September 11, 2025 15:16
Copilot finished work on behalf of AndriySvyryd September 11, 2025 15:16
Copy link
Member

@AndriySvyryd AndriySvyryd left a comment

Choose a reason for hiding this comment

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

@copilot As verification, create a simple temporary EF project, then use dotnet exec on the ef.dll with the fix to add a migration for the simple project and then to create a bundle for it. Then execute the bundle. Don't commit any of this.
Rewrite the PR summary using this template:

Fixes #{number}

**Description**
{Issue description}

**Customer impact**
{How does the reported issue affects customer's app? Are there workarounds?}

**How found**
{Was it customer reported or found during verification? How many customers are affected?}

**Regression**
{Is it a regression from a released version? Which one?}

**Testing**
{How the changes were tested}

**Risk**
{Low/Medium/High, argument why}

@Copilot Copilot AI requested a review from AndriySvyryd September 11, 2025 16:53
Copilot finished work on behalf of AndriySvyryd September 11, 2025 16:53
@AndriySvyryd AndriySvyryd marked this pull request as ready for review September 11, 2025 17:05
@AndriySvyryd AndriySvyryd requested a review from a team as a code owner September 11, 2025 17:05
@AndriySvyryd AndriySvyryd changed the title Fix dotnet-ef migrations bundle command on Linux with mixed path separators [rc2] Fix dotnet-ef migrations bundle command on Linux Sep 11, 2025
@artl93
Copy link
Member

artl93 commented Sep 11, 2025

@AndriySvyryd - Path canonicalization is a tough subject. I'm surprised the fix looks this simple. Have we checked at all with our experts like David C or Jeremy K? This seems like something the Path object should have just taken care of for you.

@AndriySvyryd
Copy link
Member

@AndriySvyryd - Path canonicalization is a tough subject. I'm surprised the fix looks this simple. Have we checked at all with our experts like David C or Jeremy K? This seems like something the Path object should have just taken care of for you.

This is a very localized fix, there might be other cases regressed by #34574 that are still not fixed. I haven't dug into why OutputPath contained a backslash in the first place.

@jkoritzinsky @JeremyKuhne @jozkee As I understand Path.Combine will preserve directory separators even if invalid but shouldn't Path.GetFullPath convert them to valid separators or throw on Linux?

@JeremyKuhne
Copy link
Member

@AndriySvyryd \ is not a directory separator on Unix and will be left as is. Path.GetFullPath will normalize repeated / and remove segments like .. and .. I'll take a look here and see if I have any other comments.

@JeremyKuhne
Copy link
Member

If you need to combine segments you should use Path.Join unless you really need Path.Combine's behavior of checking the rooting on the segments (most cases do not).

MSBuild doesn't really handle paths that have back slashes \ on Unix and it is fair to presume that any back slash in an MSBuild value is a /. That said, it would be better if you could get a resolved path from MSBuild that has the separators already normalized if at all possible as that puts the problem of not being able to open my\file out of your hands. Don't worry too much about it though, as it is kind of generally accepted that Unix paths with reserved NTFS/FAT characters are bad form and out of scope.

If you must persist a path between OSes, the best choice is to use / (Path.AltDirectorySeparator) as that will always work on both. That would include any paths that you have in MSBuild files (targets, etc.).

@AndriySvyryd
Copy link
Member

Thanks for the tips @JeremyKuhne

If you need to combine segments you should use Path.Join unless you really need Path.Combine's behavior of checking the rooting on the segments (most cases do not).

Since that's not directly related to the reported issue filed #36754 to avoid introducing extra changes in this PR.

That said, it would be better if you could get a resolved path from MSBuild that has the separators already normalized if at all possible as that puts the problem of not being able to open my\file out of your hands.

Unfortunately, we are quite limited in what we can get from MSBuild, we get the property value using

dotnet msbuild /getProperty:OutputPath

Copy link
Member

@artl93 artl93 left a comment

Choose a reason for hiding this comment

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

RC2. Thank you for the dilligence!

@AndriySvyryd AndriySvyryd merged commit a419d5d into release/10.0 Sep 12, 2025
8 checks passed
@AndriySvyryd AndriySvyryd deleted the copilot/fix-36142 branch September 12, 2025 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"dotnet-ef migrations bundle" command broken on Linux with .NET 10

5 participants