Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 4, 2025

Thanks for assigning this issue to me. I'm starting to work on it and will keep this PR's description up to date as I form a plan and make progress.

Original prompt

This section details on the original issue you should resolve

<issue_title>Stop inferring the PlatformTarget in the SDK when targeting modern .NET applications</issue_title>
<issue_description> Also, you may want to stop inferring the PlatformTarget in the SDK when targeting modern .NET applications:

<!-- Determine PlatformTarget (if not already set) from runtime identifier. -->
<Choose>
<When Condition="'$(PlatformTarget)' != '' or '$(RuntimeIdentifier)' == ''" />
<When Condition="$(RuntimeIdentifier.EndsWith('-x86')) or $(RuntimeIdentifier.Contains('-x86-'))">
<PropertyGroup>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
</When>
<When Condition="$(RuntimeIdentifier.EndsWith('-x64')) or $(RuntimeIdentifier.Contains('-x64-'))">
<PropertyGroup>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
</When>
<When Condition="$(RuntimeIdentifier.EndsWith('-arm')) or $(RuntimeIdentifier.Contains('-arm-'))">
<PropertyGroup>
<PlatformTarget>arm</PlatformTarget>
</PropertyGroup>
</When>
<When Condition="$(RuntimeIdentifier.EndsWith('-arm64')) or $(RuntimeIdentifier.Contains('-arm64-'))">
<PropertyGroup>
<PlatformTarget>arm64</PlatformTarget>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
</Otherwise>
</Choose>

Originally posted by @jkotas in #42556 (comment)
</issue_description>

Comments on the Issue (you are @copilot in this section)

@marcpopMSFT Triage: The safest solution here is to just add a When after the first one that checks if it's .net core and defaults to AnyCPU. We would need to confirm that cppcli is excluded from that condition. That solution shouldn't require other changes elsewhere. @baronfel @joeloff noted that the platform bit in the PE Header may influence registry hive/program files and other defaults - this could be impactful for already-compiled applications. @marcpopMSFT Also watch out for what value a solution sets (is it platform rather than platformtarget) and if it's set by the time this code is evaluated. @baronfel > Also watch out for what value a solution sets (is it platform rather than platformtarget) and if it's set by the time this code is evaluated.

The Platform<->PlatformTarget relationship is handled by the SDK. The Solution sets Platform for the project in the generated metaproj, and the SDK translates that to a PlatformTarget value here. This value then feeds into the logic in RuntimeIdentifierInference afterwards.</comment_new>
<comment_new>@jkotas

@joeloff noted that the platform bit in the PE Header may influence registry hive/program files and other defaults

That's true for .NET Framework. I do not think it is the case for .NET Core.</comment_new>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@jkotas
Copy link
Member

jkotas commented Dec 4, 2025

This is duplicate of #48599

@agocke
Copy link
Member

agocke commented Dec 4, 2025

Woops, didn't see that PR.

@agocke agocke closed this Dec 4, 2025
@agocke agocke deleted the copilot/stop-infer-platform-target branch December 4, 2025 22:55
Copilot AI requested a review from agocke December 4, 2025 22:55
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.

Stop inferring the PlatformTarget in the SDK when targeting modern .NET applications

3 participants