.NET: Microsoft Technologies based on the .NET software framework. Runtime: An environment required to run apps that aren't compiled to machine language.
Thank you for reaching out.
When migrating from .NET Framework (classic projects) to .NET 8 (SDK-style projects), the way platform targets are handled is fundamentally different:
- In .NET Framework
- Configuration Manager and the
.slnfile controlled platform targets like x86, x64, and AnyCPU. - Changing the platform in Configuration Manager reliably changed how the project compiled.
- In .NET 8 SDK-style Projects
- Projects default to AnyCPU unless
<PlatformTarget>is explicitly set in the.csproj. - Configuration Manager is mostly a UI convenience and doesn’t always propagate platform changes across all projects.
- Even after adding x64, some projects may still show AnyCPU due to this behavior.
Additional Insight: .sln File Behavior
The .sln file may retain AnyCPU as the default platform unless manually updated. This can cause inconsistencies between the solution-level platform and individual project-level platforms. Visual Studio may not automatically sync these settings, especially in SDK-style projects [1].
Recommended Fixes
- Manually Add x64 in Configuration Manager (for every project)
- Open Configuration Manager.
- For each project showing Any CPU, click the Platform dropdown.
- Select ** → choose x64 → copy settings from Any CPU.
- Do this for both Debug and Release.
- Save, close, and reopen Visual Studio.
This ensures all projects in the solution have an explicit x64 platform entry [1].
- Update
.csprojFiles (most reliable for SDK projects)
Add this to each project’s .csproj:
<PropertyGroup>
<PlatformTarget>x64</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
Or conditionally for Debug/Release:
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
This overrides the default AnyCPU and forces the compiler to target x64 [2] [3].
- Clean and Rebuild
After updating both Configuration Manager and .csproj files:
- Delete all
binandobjfolders. - Clean the solution.
- Rebuild → all outputs should now be x64.
Recommended Approach for Migrated WinForms Apps
If you want to enforce x64 only (recommended for native interop):
<PropertyGroup>
<PlatformTarget>x64</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
If you need flexibility, you can still allow AnyCPU alongside x64, but be explicit in your .csproj.
In Short
- .NET 8 SDK-style projects don’t fully rely on Configuration Manager — you must set
PlatformTargetin.csproj. - Ensure all projects in your solution have consistent x64 settings in both Configuration Manager and
.csproj. - Clean + rebuild ensures everything actually compiles for x64.
Microsoft References
- Configure projects to target platforms [1]
- NETSDK1032: RuntimeIdentifier and PlatformTarget must be compatible [2]
- .NET Runtime Identifier (RID) catalog [3]
- MSBuild Target Framework and Target Platform [4]
Let me know if you need any further help with this. We'll be happy to assist.
If you find this helpful, please mark this as answered.