visual-studiovisual-studio-2017visual-studio-2017-build-tools

Why is VS 2017 changing the ProjectConfigurationPlatforms section of my solution file?


I have a C# (.NET Framework) application that I'm trying to migrate from VS2015 to VS2017, and changing the project file xml to the SDK format in preparation for a migration to .NET Core.

I have 5 of the 12-ish projects in the solution migrated to the newer SDK project format. I'm finding that VS2017 is changing parts of the solution file related to two of those updated projects on me and breaking my builds.

I'm looking for help understanding why VS is making this change, and how to prevent it. I suspect that I'm missing something in the XML of my SDK projects, but I don't know what I am missing.

I have tried including a <Configurations> property in my SDK projects that lists all of the configurations that are valid, but that seems to have no effect on these two projects. It did seem to fix the issue for the other 3 SDK projects, but not these two. The only difference is that the 2 that get changed are projects for executables, and the other 3 are for libraries.

I have the following in my solution file:

        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Any CPU = Debug|Any CPU
                DebugLinux|Any CPU = DebugLinux|Any CPU
                DebugMac|Any CPU = DebugMac|Any CPU
                ReleaseLinux|Any CPU = ReleaseLinux|Any CPU
                ReleaseMac|Any CPU = ReleaseMac|Any CPU
                ReleaseWin|Any CPU = ReleaseWin|Any CPU
        EndGlobalSection

When I delete all build artifacts, load the solution into VS2017, build one of the configs of the solution, and then close VS2017 I'm finding that VS has decided to change a bunch of the configurations in my solution file. The following is a sample of the diff of the changes that VS is making.

-               {guid-redacted}.ReleaseLinux|Any CPU.ActiveCfg = ReleaseLinux|Any CPU
-               {guid-redacted}.ReleaseLinux|Any CPU.Build.0 = ReleaseLinux|Any CPU
-               {guid-redacted}.ReleaseMac|Any CPU.ActiveCfg = ReleaseMac|Any CPU
-               {guid-redacted}.ReleaseMac|Any CPU.Build.0 = ReleaseMac|Any CPU
-               {guid-redacted}.ReleaseWin|Any CPU.ActiveCfg = ReleaseWin|Any CPU
-               {guid-redacted}.ReleaseWin|Any CPU.Build.0 = ReleaseWin|Any CPU
+               {guid-redacted}.ReleaseLinux|Any CPU.ActiveCfg = Release|Any CPU
+               {guid-redacted}.ReleaseLinux|Any CPU.Build.0 = Release|Any CPU
+               {guid-redacted}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU
+               {guid-redacted}.ReleaseMac|Any CPU.Build.0 = Release|Any CPU
+               {guid-redacted}.ReleaseWin|Any CPU.ActiveCfg = Release|Any CPU
+               {guid-redacted}.ReleaseWin|Any CPU.Build.0 = Release|Any CPU

It's changing all of my Release* configurations into just plain Release. We key some of logic in the projects off of the value of the Configuration property, so these changes are wrecking that logic.

All changes are localized to the ProjectConfigurationPlatforms section; VS is, thankfully, not touching the SolutionConfigurationPlatforms section.

Any and all suggestions welcome; I'm at wits end trying to figure out what's going wrong.

Thanks!

edit: VS is also changing the project-type GUID of these projects from FAE04EC0-301F-11d3-BF4B-00C04F79EFBC to 9A19103F-16F7-4668-BE54-9A1E7A4F7556. That seems to be expected -- there's a new guid for C# project types -- but maybe it's related?


Solution

  • Figured it out. I don't know precisely why, but this undesirable behavior can be worked around by changing the project-type GUID of the SDK projects to 9A19103F-16F7-4668-BE54-9A1E7A4F7556 in the solution file before loading it.

    Seems that when VS does the auto-upgrade to the new project-type GUID it doesn't properly detect what the configurations of the project are, and defaults to just using Release and Debug.