Visual Studio replaces ProjectConfigurationPlatforms automatically based on project Platforms property
When a solution file maps a solution platform to a project platform, and the project doesn't define that platform, Visual Studio picks the first defined platform and saves this to the solution file when the solution is closed.
I believe this is the same issue reported in 2017, but closed as "not enough info" here:
https://developercommunity.visualstudio.com/content/problem/139979/do-not-want-any-cpu-in-my-sln.html
I was able to reproduce this in VS 2017 v 15.9.0
- Create a solution with a .net standard project.
- Use the configuration manager to add an x64 platform and remove the Any CPU platform.
- Save and close the solution.
- Observe that the solution doesn't mention Any CPU:
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28306.52
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClassLibrary1", "ClassLibrary1\ClassLibrary1.csproj", "{55472C98-5DA1-46A2-AADE-D21EED1ED22C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{55472C98-5DA1-46A2-AADE-D21EED1ED22C}.Debug|x64.ActiveCfg = Debug|x64
{55472C98-5DA1-46A2-AADE-D21EED1ED22C}.Debug|x64.Build.0 = Debug|x64
{55472C98-5DA1-46A2-AADE-D21EED1ED22C}.Release|x64.ActiveCfg = Release|x64
{55472C98-5DA1-46A2-AADE-D21EED1ED22C}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {746255FA-BA66-471C-92D7-1A829ECA0822}
EndGlobalSection
EndGlobal
The project file will have its Platforms property modified to include x64:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
</Project>
- Remove the Platforms element from the project file.
- Open the solution in VS.
- Save and close the solution.
- Observe that VS has updated the solution/project configuration map to x64 -> Any CPU.
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28306.52
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClassLibrary1", "ClassLibrary1\ClassLibrary1.csproj", "{55472C98-5DA1-46A2-AADE-D21EED1ED22C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{55472C98-5DA1-46A2-AADE-D21EED1ED22C}.Debug|x64.ActiveCfg = Debug|Any CPU
{55472C98-5DA1-46A2-AADE-D21EED1ED22C}.Debug|x64.Build.0 = Debug|Any CPU
{55472C98-5DA1-46A2-AADE-D21EED1ED22C}.Release|x64.ActiveCfg = Release|Any CPU
{55472C98-5DA1-46A2-AADE-D21EED1ED22C}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {746255FA-BA66-471C-92D7-1A829ECA0822}
EndGlobalSection
EndGlobal
If you change the Platforms property in the project file to <Platforms>Foo</Platforms>, then the solution file is updated to {55472C98-5DA1-46A2-AADE-D21EED1ED22C}.Debug|x64.ActiveCfg = Debug|Foo
It only appears to do this when VS is opening the solution, and not if the project files are modified after the solution is open.
It's kinda handy that VS is noticing that the solution file references a platform that's not defined in the project, but it's potentially dangerous for it to select an arbitrary platform without notifying the dev.
Visual Studio isn't picking the first defined platform. With the solution using project platform x64, and the project defining <Platforms>Foo;AnyCPU</Platforms>, the solution is changed to Any CPU. Note the space between Any and CPU added to the solution file, but not in the project file.
how do i use the autoclicker on chromebook