Skip to content

Conversation

akoeplinger
Copy link
Member

@akoeplinger akoeplinger commented Jul 18, 2025

Follow-up to #49801 and #49288

We were still seeing an error during publish, note the duplicate slashes:

error NETSDK1152: Found multiple publish output files with the same relative path: /__w/1/s/artifacts/bin/dotnet-dump/Debug/shims/net8.0/win-x64/dotnet-dump.exe, /__w/1/s/artifacts/bin/dotnet-dump/Debug//shims/net8.0/win-x64/dotnet-dump.exe, /__w/1/s/artifacts/bin/dotnet-dump/Debug/shims/net8.0/win-x86/dotnet-dump.exe, /__w/1/s/artifacts/bin/dotnet-dump/Debug//shims/net8.0/win-x86/dotnet-dump.exe, /__w/1/s/artifacts/bin/dotnet-dump/Debug/shims/net8.0/osx-x64/dotnet-dump

Use the [MSBuild]::NormalizeDirectory property function instead of Path.Combine to get a canonicalized path that doesn't contain duplicate slashes.

…tory

Follow-up to #49801 and #49288

We were still seeing an error during publish, note the duplicate slashes:

```
error NETSDK1152: Found multiple publish output files with the same relative path: /__w/1/s/artifacts/bin/dotnet-dump/Debug/shims/net8.0/win-x64/dotnet-dump.exe, /__w/1/s/artifacts/bin/dotnet-dump/Debug//shims/net8.0/win-x64/dotnet-dump.exe, /__w/1/s/artifacts/bin/dotnet-dump/Debug/shims/net8.0/win-x86/dotnet-dump.exe, /__w/1/s/artifacts/bin/dotnet-dump/Debug//shims/net8.0/win-x86/dotnet-dump.exe, /__w/1/s/artifacts/bin/dotnet-dump/Debug/shims/net8.0/osx-x64/dotnet-dump
```

Use the [MSBuild]::NormalizePath property function instead of Path.Combine to get a canonicalized path that doesn't contain duplicate slashes.
@akoeplinger akoeplinger requested review from baronfel and Copilot July 18, 2025 08:57
@akoeplinger akoeplinger requested review from a team as code owners July 18, 2025 08:57
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 a path normalization issue that was causing duplicate slashes in file paths during tool publishing, which resulted in NETSDK1152 errors about multiple publish output files with the same relative path. The change replaces [System.IO.Path]::Combine with [MSBuild]::NormalizePath to ensure canonicalized paths without duplicate directory separators.

  • Replaces Path.Combine with MSBuild.NormalizePath for PackagedShimOutputDirectory parameter
  • Affects three locations across two MSBuild target files
  • Resolves duplicate slash issues that caused publish conflicts

Reviewed Changes

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

File Description
Microsoft.NET.Publish.targets Updates PackagedShimOutputDirectory path construction in GetEmbeddedApphostPaths task
Microsoft.NET.PackTool.targets Updates PackagedShimOutputDirectory path construction in two locations for tool packaging

@ViktorHofer
Copy link
Member

ViktorHofer commented Jul 18, 2025

Shouldn't this use NormalizeDirectory?

@akoeplinger akoeplinger changed the title Use NormalizePath instead of Path.Combine for PackagedShimOutputDirectory Use NormalizeDirectory instead of Path.Combine for PackagedShimOutputDirectory Jul 18, 2025
@akoeplinger
Copy link
Member Author

akoeplinger commented Jul 18, 2025

Thanks, for some reason I always confuse the two (it still works the same way for directories though, except it won't append the trailing slash)

@akoeplinger akoeplinger merged commit b64c645 into main Jul 18, 2025
24 of 27 checks passed
@akoeplinger akoeplinger deleted the fix-shims branch July 18, 2025 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants