Skip to content

Convert sln to slnx #115818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 22, 2025
Merged

Convert sln to slnx #115818

merged 6 commits into from
May 22, 2025

Conversation

kasperk81
Copy link
Contributor

fixes #93878

@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label May 21, 2025
@kasperk81
Copy link
Contributor Author

kasperk81 commented May 21, 2025

@ViktorHofer, @edvilme converted with command:
git ls-files '*.sln' | xargs -I{} ./dotnet.sh sln {} migrate

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label May 21, 2025
@ViktorHofer
Copy link
Member

We are still missing slngen support for slnx to update all checked in solution files.

@kasperk81
Copy link
Contributor Author

Is there an ETA? There is no activity in months microsoft/slngen#644.

@ViktorHofer
Copy link
Member

We can do slngen -> sln -> slnx. That logic is in slngen.proj.

@kasperk81
Copy link
Contributor Author

slngen is broken on main. it needs an update to recognize net10. after updating to "version": "12.0.15", it produces diffs like:

diff --git a/src/libraries/Microsoft.Bcl.AsyncInterfaces/Microsoft.Bcl.AsyncInterfaces.sln b/src/libraries/Microsoft.Bcl.AsyncInterfaces/Microsoft.Bcl.AsyncInterfaces.sln
index 580c63b466b..b185f83b4af 100644
--- a/src/libraries/Microsoft.Bcl.AsyncInterfaces/Microsoft.Bcl.AsyncInterfaces.sln
+++ b/src/libraries/Microsoft.Bcl.AsyncInterfaces/Microsoft.Bcl.AsyncInterfaces.sln
@@ -25,13 +25,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{85204CF5-0C8
 EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{D6A9108E-553B-445E-A037-FA4F3140A279}"
 EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "tools\gen", "{F4939A3B-3316-4166-8AE6-34E1D0863CF5}"
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools\gen", "tools\gen", "{F4939A3B-3316-4166-8AE6-34E1D0863CF5}"
 EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "tools\src", "{1AC9674D-927D-49C4-BB42-6FF353C84275}"
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools\src", "tools\src", "{1AC9674D-927D-49C4-BB42-6FF353C84275}"
 EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "tools\ref", "{670FB605-56DB-45F0-9B48-F8A62AFE5BD9}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{8F627B90-170F-4BCE-A626-7688EC714FB4}"
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools\ref", "tools\ref", "{670FB605-56DB-45F0-9B48-F8A62AFE5BD9}"
 EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -91,12 +89,9 @@ Global
                {D0F1936C-CF7C-4448-9F90-B9DEABE89EBB} = {D6A9108E-553B-445E-A037-FA4F3140A279}
                {59CE8DDB-AFFD-4C6F-B09F-94DE4DD0AAEA} = {F4939A3B-3316-4166-8AE6-34E1D0863CF5}
                {0225750F-4DC0-4C71-9B33-314ACA0EF682} = {F4939A3B-3316-4166-8AE6-34E1D0863CF5}
-               {F4939A3B-3316-4166-8AE6-34E1D0863CF5} = {8F627B90-170F-4BCE-A626-7688EC714FB4}
                {272C69D8-6BED-4CE0-BD62-9F993989374E} = {1AC9674D-927D-49C4-BB42-6FF353C84275}
                {FCA0C2EA-4A82-4B3F-A9B5-E0B5200866BF} = {1AC9674D-927D-49C4-BB42-6FF353C84275}
-               {1AC9674D-927D-49C4-BB42-6FF353C84275} = {8F627B90-170F-4BCE-A626-7688EC714FB4}
                {9957B23B-3C95-4200-A6D9-F05BAF6DC7A7} = {670FB605-56DB-45F0-9B48-F8A62AFE5BD9}
-               {670FB605-56DB-45F0-9B48-F8A62AFE5BD9} = {8F627B90-170F-4BCE-A626-7688EC714FB4}
        EndGlobalSection
        GlobalSection(ExtensibilityGlobals) = postSolution
                SolutionGuid = {A835CEDB-E9E2-49EE-8499-BD7FDD984E53}

which fails dotnet sln migrate:

One or more errors occurred. (One or more errors occurred. (Project name 'Mono.Linker' already exists in the 'Root' solution folder.))

the error is correct, new slngen has introduced this bug.

@ViktorHofer
Copy link
Member

Any idea which commit in slngen regressed this?

@kasperk81
Copy link
Contributor Author

Any idea which commit in slngen regressed this?

no idea. #105239 was an year ago but if you want to wait for slngen i will close this pr. #93878 doesn't say anything about slngen precondition

@kasperk81 kasperk81 closed this May 21, 2025
@ViktorHofer ViktorHofer reopened this May 22, 2025
@ViktorHofer
Copy link
Member

ViktorHofer commented May 22, 2025

@kasperk81 dotnet build src/libraries/slngen.proj works fine for me with these changes:

From fe4505215d43c0c13a43d3a7382a9ad88134dcb9 Mon Sep 17 00:00:00 2001
From: Viktor Hofer <viktor.hofer@microsoft.com>
Date: Thu, 22 May 2025 09:27:28 +0200
Subject: [PATCH] Add dotnet sln migrate command and update slngen

---
 .config/dotnet-tools.json |  2 +-
 src/libraries/slngen.proj | 12 ++++++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json
index d5e70ab3de1..ac59f400004 100644
--- a/.config/dotnet-tools.json
+++ b/.config/dotnet-tools.json
@@ -21,7 +21,7 @@
       ]
     },
     "microsoft.visualstudio.slngen.tool": {
-      "version": "11.1.0",
+      "version": "12.0.15",
       "commands": [
         "slngen"
       ]
diff --git a/src/libraries/slngen.proj b/src/libraries/slngen.proj
index 3118a1e1545..c06b8c0e403 100644
--- a/src/libraries/slngen.proj
+++ b/src/libraries/slngen.proj
@@ -8,7 +8,8 @@
 
   <ItemGroup>
     <!-- Unless a "/p:SolutionNameOverride" property is passed in, glob all solutions under src/libraries. -->
-    <SolutionFile Include="$(MSBuildThisFileDirectory)$(SolutionNameOverride)\*.sln" />
+    <SolutionFile Include="$(MSBuildThisFileDirectory)$(SolutionNameOverride)\*.slnx"
+                  Exclude="$(MSBuildThisFileDirectory)Fuzzing\*.slnx" />
   </ItemGroup>
 
   <Target Name="UpdateSolutionFile"
@@ -25,12 +26,19 @@
 
     <!-- Delete temporary template file -->
     <Delete Files="%(SolutionFile.ProjFilePath)" />
+
+    <!-- Invoke dotnet sln migrate as slngen doesn't support slnx yet. -->
+    <Exec Command="&quot;$(RepoRoot)dotnet$(ScriptExt)&quot; sln migrate &quot;%(SolutionFile.SlnFilePath)&quot;" />
+
+    <!-- Delete the intermediate sln file. -->
+    <Delete Files="%(SolutionFile.SlnFilePath)" />
   </Target>
 
   <Target Name="GetSolutionFiles">
     <ItemGroup>
       <!-- Add attributes that require a separate item mutation. -->
-      <SolutionFile ProjFilePath="%(RelativeDir)%(Filename).proj" />
+      <SolutionFile ProjFilePath="%(RelativeDir)%(Filename).proj"
+                    SlnFilePath="%(RelativeDir)%(Filename).sln" />
     </ItemGroup>
   </Target>
 </Project>

Copy link
Member

@ViktorHofer ViktorHofer left a comment

Choose a reason for hiding this comment

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

@kasperk81 thanks a lot for the hard work here. I think we can merge this as is and I will submit a follow-up PR with the slngen.proj changes.

@kasperk81
Copy link
Contributor Author

thanks @ViktorHofer. i checked Allow edits and access to secrets by maintainers so you can push here

@ViktorHofer
Copy link
Member

/ba-g failures are entirely unrelated as we don't build with slnxs. The other changes in this PR got successfully validated.

@ViktorHofer ViktorHofer merged commit bb48410 into dotnet:main May 22, 2025
157 of 162 checks passed
@kasperk81 kasperk81 deleted the slnx branch May 22, 2025 15:50
@@ -361,7 +361,7 @@ private static string GenerateLocalRunHelperScript(IFuzzer fuzzer)
private static void WorkaroundOneFuzzTaskNotAcceptingMultipleJobs(IFuzzer[] fuzzers)
{
string yamlPath = Environment.CurrentDirectory;
while (!File.Exists(Path.Combine(yamlPath, "DotnetFuzzing.sln")))
while (!File.Exists(Path.Combine(yamlPath, "DotnetFuzzing.slnx")))
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Misses sln in error message

@MichalStrehovsky
Copy link
Member

With this I can no longer use the build.cmd -vs nativeaot shortcut to open solution files. VS opens but I get:

The selected file is not a valid solution file

Do we need something extra for that?

@MichalStrehovsky
Copy link
Member

With this I can no longer use the build.cmd -vs nativeaot shortcut to open solution files. VS opens but I get:

Never mind, updating VS seems to have fixed it.

@jakobbotsch
Copy link
Member

For me build.cmd -vs coreclr.sln also does not work, and I can not get any other variation to work.

❯ .\build.cmd -vs coreclr.sln
C:\dev\dotnet\runtime\eng\build.ps1 : Passed in solution cannot be resolved.
At line:1 char:1
+ & 'C:\dev\dotnet\runtime\eng\build.ps1' -vs coreclr.sln
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,build.ps1

❯ .\build.cmd -vs coreclr
C:\dev\dotnet\runtime\eng\build.ps1 : Passed in solution cannot be resolved.
At line:1 char:1
+ & 'C:\dev\dotnet\runtime\eng\build.ps1' -vs coreclr
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,build.ps1

❯ .\build.cmd -vs coreclr.slnx

  Determining projects to restore...
  All projects are up-to-date for restore.
  cdac-build-tool -> C:\dev\dotnet\runtime\artifacts\bin\coreclr\windows.x64.Debug\cdac-build-tool\cdac-build-tool.dll
  Executing C:\dev\dotnet\runtime\src\coreclr\"build-runtime.cmd" -x64 -debug -configureonly -os windows -msbuild -outputrid win-x64 -cmakeargs "-DCLR_DOTNET_RID=win-x64" -cmakeargs "-DCLR_DOTN
  ET_HOST_PATH=C:\dev\dotnet\runtime\.dotnet\dotnet.exe" -cmakeargs "-DCDAC_BUILD_TOOL_BINARY_PATH=C:\dev\dotnet\runtime\artifacts\bin\coreclr\windows.x64.Debug\cdac-build-tool\cdac-build-tool.
  dll"
  BUILD: Starting Build at 11:59:29.27
  BUILD: Commencing CoreCLR product build
  BUILD: Checking prerequisites
  BUILD: Using CMake from C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe
  BUILD: Number of processor cores 16
  BUILD: Commencing build of native components for windows.x64.Debug
  BUILD: Using environment: "C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Auxiliary\Build\vcvarsall.bat" amd64
  **********************************************************************
  ** Visual Studio 2022 Developer Command Prompt v17.14.2-pre.1.0
  ** Copyright (c) 2022 Microsoft Corporation
  **********************************************************************
  [vcvarsall.bat] Environment initialized for: 'x64'
  BUILD: Regenerating the Visual Studio solution
  Calling "C:\dev\dotnet\runtime\eng\native\gen-buildsys.cmd" "C:\dev\dotnet\runtime\src\coreclr" "C:\dev\dotnet\runtime\artifacts\obj\coreclr\windows.x64.Debug\ide" 17.0 x64 windows  "-DCLR_CM
  AKE_TARGET_ARCH=x64" "-DCLR_CMAKE_TARGET_OS=windows" "-DCLI_CMAKE_FALLBACK_OS=win10" "-DCLR_CMAKE_PGO_INSTRUMENT=0" "-DCLR_CMAKE_OPTDATA_PATH=" "-DCLR_CMAKE_PGO_OPTIMIZE=0" "-DCDAC_BUILD_TOOL
  _BINARY_PATH=C:\dev\dotnet\runtime\artifacts\bin\coreclr\windows.x64.Debug\cdac-build-tool\cdac-build-tool.dll" "-DCLR_DOTNET_HOST_PATH=C:\dev\dotnet\runtime\.dotnet\dotnet.exe" "-DCLR_DOTNET
  _RID=win-x64"
  "C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe "-DCMAKE_INSTALL_PREFIX=C:/dev/dotnet/runtime/artifacts/bin/coreclr/win
  dows.x64.Debug" "-DCLR_CMAKE_HOST_ARCH=x64"  -A x64  "-DCMAKE_SYSTEM_VERSION=10.0" "-DCLR_CMAKE_TARGET_ARCH=x64" "-DCLR_CMAKE_TARGET_OS=windows" "-DCLI_CMAKE_FALLBACK_OS=win10" "-DCLR_CMAKE_P
  GO_INSTRUMENT=0" "-DCLR_CMAKE_OPTDATA_PATH=" "-DCLR_CMAKE_PGO_OPTIMIZE=0" "-DCDAC_BUILD_TOOL_BINARY_PATH=C:\dev\dotnet\runtime\artifacts\bin\coreclr\windows.x64.Debug\cdac-build-tool\cdac-bui
  ld-tool.dll" "-DCLR_DOTNET_HOST_PATH=C:\dev\dotnet\runtime\.dotnet\dotnet.exe" "-DCLR_DOTNET_RID=win-x64" --no-warn-unused-cli -G Visual Studio 17 2022 -B "C:\dev\dotnet\runtime\artifacts\obj
  \coreclr\windows.x64.Debug\ide" -S "C:\dev\dotnet\runtime\src\coreclr""
  Not searching for unused variables given on the command line.
  -- Selecting Windows SDK version 10.0.26100.0 to target Windows 10.0.
  -- Using CMake version 3.31.6-msvc6
  -- ZLIB_HEADER_VERSION: 1.3.1
  -- ZLIBNG_HEADER_VERSION: 2.2.1
  -- Arch detected: 'x86_64'
  -- Basearch of 'x86_64' has been detected as: 'x86'
  -- Architecture-specific source files: arch/x86/x86_features.c;arch/x86/chunkset_sse2.c;arch/x86/compare256_sse2.c;arch/x86/slide_hash_sse2.c;arch/x86/adler32_ssse3.c;arch/x86/chunkset_ssse3.
  c;arch/x86/adler32_sse42.c;arch/x86/crc32_pclmulqdq.c;arch/x86/slide_hash_avx2.c;arch/x86/chunkset_avx2.c;arch/x86/compare256_avx2.c;arch/x86/adler32_avx2.c;arch/x86/adler32_avx512.c;arch/x86
  /adler32_avx512_vnni.c;arch/x86/crc32_vpclmulqdq.c
  -- The following features have been enabled:

   * XSAVE, Support XSAVE intrinsics using ""
   * SSSE3_ADLER32, Support SSSE3-accelerated adler32, using ""
   * SSE42_CRC, Support SSE4.2 optimized adler32 hash generation, using ""
   * PCLMUL_CRC, Support CRC hash generation using PCLMULQDQ, using " "
   * AVX2_SLIDEHASH, Support AVX2 optimized slide_hash, using "/arch:AVX2"
   * AVX2_CHUNKSET, Support AVX2 optimized chunkset, using "/arch:AVX2"
   * AVX2_COMPARE256, Support AVX2 optimized compare256, using "/arch:AVX2"
   * AVX2_ADLER32, Support AVX2-accelerated adler32, using "/arch:AVX2"
   * AVX512_ADLER32, Support AVX512-accelerated adler32, using "/arch:AVX512"
   * AVX512VNNI_ADLER32, Support AVX512VNNI adler32, using "/arch:AVX512"
   * VPCLMUL_CRC, Support CRC hash generation using VPCLMULQDQ, using "  /arch:AVX512"
   * WITH_GZFILEOP, Compile with support for gzFile related functions
   * ZLIB_COMPAT, Compile with zlib compatible API
   * WITH_SANITIZER, Enable sanitizer support
   * WITH_GTEST, Build gtest_zlib
   * WITH_OPTIM, Build with optimisation
   * WITH_NEW_STRATEGIES, Use new strategies
   * WITH_RUNTIME_CPU_DETECTION, Build with runtime CPU detection
   * WITH_AVX2, Build with AVX2
   * WITH_AVX512, Build with AVX512
   * WITH_AVX512VNNI, Build with AVX512 VNNI
   * WITH_SSE2, Build with SSE2
   * WITH_SSSE3, Build with SSSE3
   * WITH_SSE42, Build with SSE42
   * WITH_PCLMULQDQ, Build with PCLMULQDQ
   * WITH_VPCLMULQDQ, Build with VPCLMULQDQ

  -- The following features have been disabled:

   * ZLIB_SYMBOL_PREFIX, Publicly exported symbols DO NOT have a custom prefix
   * ZLIB_ENABLE_TESTS, Build test binaries
   * ZLIBNG_ENABLE_TESTS, Test zlib-ng specific API
   * WITH_FUZZERS, Build test/fuzz
   * WITH_BENCHMARKS, Build test/benchmarks
   * WITH_BENCHMARK_APPS, Build application benchmarks
   * WITH_NATIVE_INSTRUCTIONS, Instruct the compiler to use the full instruction set on this host (gcc/clang -march=native)
   * WITH_MAINTAINER_WARNINGS, Build with project maintainer warnings
   * WITH_CODE_COVERAGE, Enable code coverage reporting
   * WITH_INFLATE_STRICT, Build with strict inflate distance checking
   * WITH_INFLATE_ALLOW_INVALID_DIST, Build with zero fill for inflate invalid distances
   * INSTALL_UTILS, Copy minigzip and minideflate during install

  -- Build type is ''
  -- Compiler is not EMSCRIPTEN
  Read file version from native version header at 'C:/dev/dotnet/runtime/artifacts/obj/_version.h'.
  -- Configuring done (5.9s)
  -- Generating done (3.7s)
  -- Build files have been written to: C:/dev/dotnet/runtime/artifacts/obj/coreclr/windows.x64.Debug/ide
  BUILD: Build succeeded.  Finished at 11:59:41.60
  BUILD: Product binaries are available at C:\dev\dotnet\runtime\artifacts\bin\coreclr\windows.x64.Debug
C:\dev\dotnet\runtime\eng\build.ps1 : Unable to find the CoreCLR solution file at C:\dev\dotnet\runtime\artifacts\obj\coreclr\windows.x64.Debug\ide\CoreCLR.slnx.
At line:1 char:1
+ & 'C:\dev\dotnet\runtime\eng\build.ps1' -vs coreclr.slnx
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,build.ps1

C:\dev\dotnet\runtime\eng\build.ps1 : The term 'C:\dev\dotnet\runtime\artifacts\obj\coreclr\windows.x64.Debug\ide\CoreCLR.slnx' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ & 'C:\dev\dotnet\runtime\eng\build.ps1' -vs coreclr.slnx
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\dev\dotnet\r...de\CoreCLR.slnx:String) [build.ps1], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException,build.ps1

@ViktorHofer
Copy link
Member

ViktorHofer commented May 23, 2025

Looks like coreclr.sln gets auto-generated as part of the build. I don't see it checked-in. Do you know how that is done?
Meanwhile we should probably allow both extensions to be opened by the -vs switch.

@jakobbotsch
Copy link
Member

Looks like coreclr.sln gets auto-generated as part of the build. I don't see it checked-in. Do you know how that is done? Meanwhile we should probably allow both extensions to be opened by the -vs switch.

I think cmake is creating it. cc @jkoritzinsky

@ViktorHofer
Copy link
Member

#115935

@kasperk81
Copy link
Contributor Author

cmake slnx support isn't there yet https://gitlab.kitware.com/cmake/cmake/-/issues/25887

SimaTian pushed a commit that referenced this pull request May 27, 2025
* convert sln to slnx

* Update slngen.proj

* Update dotnet-tools.json

* Update slnx files based on slngen.proj

---------

Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com>
@github-actions github-actions bot locked and limited conversation to collaborators Jun 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
community-contribution Indicates that the PR has been added by a community member needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use slnx files instead of sln per library node
5 participants