Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 10, 2025

Projects whose assembly name matches a culture name (cs, de, es, fr, it, ja, ko, pl, pt-BR, ru, tr, zh-Hans, zh-Hant) can fail to build on Unix systems when using packages that deploy culture-specific resources.

The issue occurs because:

  1. The apphost executable is named $(AssemblyName)$(_NativeExecutableExtension)
  2. On Unix, $(_NativeExecutableExtension) is empty, so the file is just named after the assembly (e.g., "cs")
  3. Packages with localized resources create culture directories with the same names (e.g., "cs/")
  4. MSBuild fails when trying to copy the apphost file to a location that's already a directory

Example failure:

dotnet new console -o cs
cd cs
dotnet add package Microsoft.CodeAnalysis.CSharp
dotnet build

Results in:

error MSB3024: Could not copy the file "cs/obj/Debug/net10.0/apphost" 
to the destination file "bin/Debug/net10.0/cs", because the destination is a folder instead of a file.

Changes Made

Added NETSDK1229 Warning:

  • New warning message in Strings.resx with clear description and solutions
  • Suggests renaming the application or restricting SatelliteResourceLanguages property

Implemented Detection Target:

  • Added _WarnForApphostCultureCollision target in Microsoft.NET.Sdk.targets
  • Runs after ResolvePackageAssets to ensure ResourceCopyLocalItems are available
  • Only executes for executable projects with UseAppHost=true
  • Compares apphost filename with culture metadata from resource packages
  • Issues warning when collision is detected

Warning Message:

NETSDK1229: The executable file name '{0}' may conflict with resource directories for culture '{1}'. Consider renaming the application or restricting the SatelliteResourceLanguages property to avoid this conflict.

This provides early detection of the collision issue with clear guidance on how to resolve it, improving the developer experience for this edge case.

Fixes #49731.


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

Copilot AI changed the title [WIP] apphost file naming may collide with resource directory on Unix systems Add warning for apphost file naming collision with culture directories (NETSDK1229) Jul 10, 2025
Copilot AI requested a review from baronfel July 10, 2025 18:05
Copilot finished work on behalf of baronfel July 10, 2025 18:05
@baronfel baronfel marked this pull request as ready for review July 11, 2025 01:08
Copilot AI review requested due to automatic review settings July 11, 2025 01:08
Copy link
Contributor

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

Adds an early warning (NETSDK1229) when an apphost executable name matches a culture directory name to prevent build failures on Unix.

  • Introduces _WarnForApphostCultureCollision MSBuild target to detect name collisions after package resolution.
  • Adds the NETSDK1229 message to Strings.resx and updates all XLF localization files.
  • Adds a new test in AppHostTests.cs to verify the warning is emitted.

Reviewed Changes

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

File Description
test/Microsoft.NET.Build.Tests/AppHostTests.cs New test to confirm NETSDK1229 warning is emitted
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets Added _WarnForApphostCultureCollision target
src/Tasks/Common/Resources/Strings.resx Defined new warning string ApphostCollisionWithCultureDirectory
src/Tasks/Common/Resources/xlf/Strings.*.xlf Manually inserted new XLF entries for NETSDK1229

<target state="translated">NETSDK1177: 無法簽署 AppHost,錯誤碼 {1}: {0}</target>
<note>{StrBegins="NETSDK1177: "}</note>
</trans-unit>
<trans-unit id="ApphostCollisionWithCultureDirectory">
Copy link

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

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

Avoid manually editing .xlf localization files. Instead, use the '/t:UpdateXlf' MSBuild target to regenerate these entries and ensure proper translation workflow.

Copilot generated this review using guidance from repository custom instructions.
@baronfel baronfel marked this pull request as draft July 11, 2025 01:09
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.

apphost file naming may collide with resource directory on Unix systems

2 participants