microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
22.99k stars 6.35k forks source link

Vcpkg installs dependencies after module source scan #41479

Open sylveon opened 3 days ago

sylveon commented 3 days ago

Describe the bug Vcpkg installs dependencies after the compiler scans for C++20 module dependencies, leading to build failure.

Environment

To Reproduce Steps to reproduce the behavior:

  1. Create a VS project using C++20 modules, and Vcpkg manifest mode. Have one of the ixx file import a header from a vcpkg dependency.
  2. Build the project with the dependencies not yet installed.
  3. Observe that vcpkg installs dependencies after source is scanned for dependencies, leading to build failures

Expected behavior Vcpkg should install dependencies first and I should not have to built the project twice to get a successful build.

Failure logs

1>------ Build started: Project: TranslucentTB.Core, Configuration: Debug x64 ------
1>Scanning sources for module dependencies...
1>CoreThread.ixx
1>WinEventHookWatcher.ixx
1>EventQueue.ixx
1>RootHandler.ixx
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(6,8): error C1083: Cannot open header unit file: 'member_thunk/member_thunk.hpp': No such file or directory
1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(503,5): warning MSB8074: Cannot read Module Dependencies file x64\Debug\WinEventHookWatcher.ixx.module.json: Expecting element 'root' from namespace ''.. Encountered 'None'  with name '', namespace ''.  The build order might be incorrect.
1>windows.h
1>base.h
1>thread
1>memory
1>functional
1>queue
1>algorithm
1>list
1>Installing vcpkg dependencies to Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\vcpkg_installed\x64-windows\
1>"Z:\vcpkg\vcpkg.exe" install  --x-wait-for-lock --triplet "x64-windows" --vcpkg-root "Z:\vcpkg\\" "--x-manifest-root=Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\\" "--x-install-root=Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\vcpkg_installed\x64-windows\\" --overlay-ports="Z:\TranslucentTB\vcpkg\ports"
1>A suitable version of cmake was not found (required v3.30.1).
1>Downloading https://github.com/Kitware/CMake/releases/download/v3.30.1/cmake-3.30.1-windows-i386.zip
1>Extracting cmake...
1>A suitable version of 7zip was not found (required v24.8.0).
1>Downloading https://github.com/ip7z/7zip/releases/download/24.08/7z2408-extra.7z
1>Extracting 7zip...
1>A suitable version of 7zr was not found (required v24.8.0).
1>Downloading https://github.com/ip7z/7zip/releases/download/24.08/7zr.exe
1>Detecting compiler hash for triplet x64-windows...
1>Compiler found: C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.42.34321/bin/Hostx64/x64/cl.exe
1>The following packages will be built and installed:
1>    member-thunk:x64-windows@0.0.1#1 -- Z:\TranslucentTB\vcpkg\ports\member-thunk
1>Restored 0 package(s) from C:\Users\Sylveon\AppData\Local\vcpkg\archives in 511 us. Use --debug to see more details.
1>Installing 1/1 member-thunk:x64-windows@0.0.1#1...
1>Building member-thunk:x64-windows@0.0.1#1...
1>Z:\TranslucentTB\vcpkg\ports\member-thunk: info: installing overlay port from here
1>-- Downloading https://github.com/sylveon/member_thunk/archive/3acf1402af87de495f073233c9b842c230a7fb12.tar.gz -> sylveon-member_thunk-3acf1402af87de495f073233c9b842c230a7fb12.tar.gz...
1>-- Extracting source Z:/vcpkg/downloads/sylveon-member_thunk-3acf1402af87de495f073233c9b842c230a7fb12.tar.gz
1>-- Using source at Z:/vcpkg/buildtrees/member-thunk/src/c230a7fb12-78beb49d8f.clean
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/default_heap.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/default_heap.impl.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/details
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/details/function_traits.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/details/heap
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/details/heap/memory.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/details/heap/memory.impl.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/details/heap/region.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/details/heap/region.impl.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/details/list.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/details/list.impl.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/details/thunk
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/details/thunk/thunk.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/details/thunk/thunk.impl.arm64.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/details/thunk/thunk.impl.x64.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/error
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/error/exception.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/error/heap_not_empty.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/error/invalid_memory_layout.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/error/page_executable.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/error/page_full.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/error/region_full.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/error/region_not_empty.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/error/win32_error.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/heap.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/heap.impl.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/lock
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/lock/null_lock.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/lock/slim_lock.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/member_thunk.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/page.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/include/member_thunk/page.impl.hpp
1>-- Installing: Z:/vcpkg/packages/member-thunk_x64-windows/share/member-thunk/copyright
1>-- Performing post-build validation
1>Stored binaries in 1 destinations in 77.9 ms.
1>Elapsed time to handle member-thunk:x64-windows: 1.3 s
1>member-thunk:x64-windows package ABI: 5b87550bf59f783c896ac3115a8b8874a1b1af4de582342aa5ede638a4105433
1>Total install time: 1.3 s
1>member-thunk is header-only and can be used from CMake via:
1>
1>  find_path(MEMBER_THUNK_INCLUDE_DIRS "member_thunk/default_heap.hpp")
1>  target_include_directories(main PRIVATE ${MEMBER_THUNK_INCLUDE_DIRS})
1>
1>Compiling...
1>memory
1>WinEventHookWatcher.ixx
1>base.h
1>queue
1>thread
1>list
1>algorithm
1>functional
1>windows.h
1>Z:\Projects\ttb-rewrite\TranslucentTB\packages\Microsoft.Windows.ImplementationLibrary.1.0.240803.1\include\wil\result_macros.h(4095,20): message : sorry: 'inline' function definition for 'HRESULT wil::details::ResultFromExceptionSeh(const wil::DiagnosticsInfo &,void *,wil::SupportedExceptions,wil::details::IFunctor &) noexcept' could not be written to module due to unrecognized expression or statement at 'Z:\Projects\ttb-rewrite\TranslucentTB\packages\Microsoft.Windows.ImplementationLibrary.1.0.240803.1\include\wil\result_macros.h(4098,9)'.
1>Z:\Projects\ttb-rewrite\TranslucentTB\packages\Microsoft.Windows.ImplementationLibrary.1.0.240803.1\include\wil\result_macros.h(4095,20): message : If possible please provide a repro here: https://developercommunity.visualstudio.com
1>(compiling source file 'WinEventHookWatcher.ixx')
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(5,13): error C7612: could not find header unit for 'map'
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(6,39): error C7612: could not find header unit for 'member_thunk/member_thunk.hpp'
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(7,22): error C7612: could not find header unit for 'winrt/base.h'
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(8,37): error C2230: could not find module 'TranslucentTB.Core.EventQueue'
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(15,23): error C2061: syntax error: identifier 'EventQueue'
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(45,13): error C2143: syntax error: missing ';' before '*'
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(45,3): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(45,22): error C2238: unexpected token(s) preceding ';'
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(46,3): error C2653: 'member_thunk': is not a class or namespace name
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(46,22): error C3646: 'm_Thunks': unknown override specifier
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(46,17): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(49,28): error C2039: 'map': is not a member of 'std'
1>    C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.42.34321\include\new(20,1):
1>    see declaration of 'std'
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(49,3): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(49,39): error C2065: 'EventType': undeclared identifier
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(49,28): error C7568: argument list missing after assumed function template 'map'
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(49,28): error C2062: type 'unknown-type' unexpected
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(49,67): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(16,12): error C2065: 'queue': undeclared identifier
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(17,13): error C2653: 'member_thunk': is not a class or namespace name
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(17,27): error C3861: 'allocate_page': identifier not found
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(16,4): error C2614: 'TranslucentTB::Core::WinEventHookWatcher': illegal member initialization: 'm_Queue' is not a base or member
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(17,4): error C2614: 'TranslucentTB::Core::WinEventHookWatcher': illegal member initialization: 'm_Thunks' is not a base or member
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(19,25): error C2065: 'm_Thunks': undeclared identifier
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(19,15): error C2737: 'handler': const object must be initialized
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(20,97): error C3536: 'handler': cannot be used before it is initialized
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(20,32): error C2664: 'HWINEVENTHOOK TranslucentTB::Core::WinEventHookWatcher::CreateHook(DWORD,DWORD,WINEVENTPROC)': cannot convert argument 3 from 'int' to 'WINEVENTPROC'
1>    Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(20,97):
1>    Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or parenthesized function-style cast
1>    Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(29,24):
1>    see declaration of 'TranslucentTB::Core::WinEventHookWatcher::CreateHook'
1>    Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(20,32):
1>    while trying to match the argument list '(int, int, int)'
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(21,30): error C2664: 'HWINEVENTHOOK TranslucentTB::Core::WinEventHookWatcher::CreateHook(DWORD,DWORD,WINEVENTPROC)': cannot convert argument 3 from 'int' to 'WINEVENTPROC'
1>    Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(21,84):
1>    Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or parenthesized function-style cast
1>    Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(29,24):
1>    see declaration of 'TranslucentTB::Core::WinEventHookWatcher::CreateHook'
1>    Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(21,30):
1>    while trying to match the argument list '(int, int, int)'
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(22,25): error C2664: 'HWINEVENTHOOK TranslucentTB::Core::WinEventHookWatcher::CreateHook(DWORD,DWORD,WINEVENTPROC)': cannot convert argument 3 from 'int' to 'WINEVENTPROC'
1>    Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(22,74):
1>    Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or parenthesized function-style cast
1>    Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(29,24):
1>    see declaration of 'TranslucentTB::Core::WinEventHookWatcher::CreateHook'
1>    Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(22,25):
1>    while trying to match the argument list '(int, int, int)'
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(23,29): error C2664: 'HWINEVENTHOOK TranslucentTB::Core::WinEventHookWatcher::CreateHook(DWORD,DWORD,WINEVENTPROC)': cannot convert argument 3 from 'int' to 'WINEVENTPROC'
1>    Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(23,86):
1>    Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or parenthesized function-style cast
1>    Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(29,24):
1>    see declaration of 'TranslucentTB::Core::WinEventHookWatcher::CreateHook'
1>    Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(23,29):
1>    while trying to match the argument list '(int, int, int)'
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(25,4): error C2065: 'm_Thunks': undeclared identifier
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(31,11): error C2653: 'winrt': is not a class or namespace name
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(31,18): error C3861: 'check_pointer': identifier not found
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(38,25): error C2065: 's_EventTypeMap': undeclared identifier
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(38,20): error C2737: 'it': const object must be initialized
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(38,53): error C3536: 'it': cannot be used before it is initialized
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(38,59): error C2065: 's_EventTypeMap': undeclared identifier
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(40,6): error C2065: 'm_Queue': undeclared identifier
1>Z:\Projects\ttb-rewrite\TranslucentTB\TranslucentTB.Core\WinEventHookWatcher.ixx(40,25): error C2065: 'Event': undeclared identifier
jimwang118 commented 3 days ago

Please provide a test case, thank you.

sylveon commented 3 days ago

@jimwang118 clone https://github.com/sylveon/vcpkg-modules-issue, and open the solution in a VS IDE with vcpkg integration enabled vcpkg integrate install

Build the solution once, observe failure because Scanning sources for module dependencies... happens before Installing vcpkg dependencies:

Build started at 03:58...
1>------ Build started: Project: ConsoleApplication2, Configuration: Debug x64 ------
1>Scanning sources for module dependencies...
1>ConsoleApplication2.ixx
1>Z:\Throwaway\ConsoleApplication2\ConsoleApplication2.ixx(1,8): error C1083: Cannot open header unit file: 'fmt/format.h': No such file or directory
1>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(503,5): warning MSB8074: Cannot read Module Dependencies file ConsoleA.eb99e311\x64\Debug\ConsoleApplication2.ixx.module.json: Expecting element 'root' from namespace ''.. Encountered 'None'  with name '', namespace ''.  The build order might be incorrect.
1>Installing vcpkg dependencies to Z:\Throwaway\ConsoleApplication2\vcpkg_installed\x64-windows\
1>"Z:\vcpkg\vcpkg.exe" install  --x-wait-for-lock --triplet "x64-windows" --vcpkg-root "Z:\vcpkg\\" "--x-manifest-root=Z:\Throwaway\ConsoleApplication2\\" "--x-install-root=Z:\Throwaway\ConsoleApplication2\vcpkg_installed\x64-windows\\"
1>Detecting compiler hash for triplet x64-windows...
1>Compiler found: C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.42.34226/bin/Hostx64/x64/cl.exe
1>The following packages will be built and installed:
1>    fmt:x64-windows@10.2.1#2
1>  * vcpkg-cmake:x64-windows@2024-04-23
1>  * vcpkg-cmake-config:x64-windows@2024-05-23
1>Additional packages (*) will be modified to complete this operation.
1>Restored 3 package(s) from C:\Users\Sylveon\AppData\Local\vcpkg\archives in 61.5 ms. Use --debug to see more details.
1>Installing 1/3 vcpkg-cmake-config:x64-windows@2024-05-23...
1>Elapsed time to handle vcpkg-cmake-config:x64-windows: 2.45 ms
1>vcpkg-cmake-config:x64-windows package ABI: 4e85a7fb39d4b005ff9c2c93fd745b9880e0ed0d9c578a05e1c409843145e5b2
1>Installing 2/3 vcpkg-cmake:x64-windows@2024-04-23...
1>Elapsed time to handle vcpkg-cmake:x64-windows: 2.71 ms
1>vcpkg-cmake:x64-windows package ABI: 846de83b4df1dad300f045832b9f15280edba5be7ae3cc9cfbf8b2fcc6b35425
1>Installing 3/3 fmt:x64-windows@10.2.1#2...
1>Elapsed time to handle fmt:x64-windows: 7.46 ms
1>fmt:x64-windows package ABI: cc6434228732dc0525c9e3010f69f0700c69bdd80dcb7c44190908b39adbcd73
1>Total install time: 12.7 ms
1>The package fmt provides CMake targets:
1>
1>    find_package(fmt CONFIG REQUIRED)
1>    target_link_libraries(main PRIVATE fmt::fmt)
1>
1>    # Or use the header-only version
1>    find_package(fmt CONFIG REQUIRED)
1>    target_link_libraries(main PRIVATE fmt::fmt-header-only)
1>
1>Compiling...
1>ConsoleApplication2.ixx
1>Z:\Throwaway\ConsoleApplication2\ConsoleApplication2.ixx(1,22): error C7612: could not find header unit for 'fmt/format.h'
1>Z:\Throwaway\ConsoleApplication2\ConsoleApplication2.ixx(5,5): error C2653: 'fmt': is not a class or namespace name
1>Z:\Throwaway\ConsoleApplication2\ConsoleApplication2.ixx(5,10): error C3861: 'print': identifier not found
1>Done building project "ConsoleApplication2.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 03:58 and took 04.007 seconds ==========

Build the solution again, and notice it now works because the dependency was installed during the previous failing build:

Build started at 04:02...
1>------ Build started: Project: ConsoleApplication2, Configuration: Debug x64 ------
1>Scanning sources for module dependencies...
1>ConsoleApplication2.ixx
1>Compiling...
1>ConsoleApplication2.ixx
1>LINK : Z:\Throwaway\ConsoleApplication2\x64\Debug\ConsoleApplication2.exe not found or not built by the last incremental link; performing full link
1>ConsoleApplication2.vcxproj -> Z:\Throwaway\ConsoleApplication2\x64\Debug\ConsoleApplication2.exe
1>'pwsh.exe' is not recognized as an internal or external command,
1>operable program or batch file.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 04:02 and took 01.795 seconds ==========

This should not be happening, the first build from a clean clone should succeed, i.e. vcpkg should install dependencies before the source scan.

jimwang118 commented 3 days ago

The git repository you provided is empty, that is, there is no cmakelists.txt, C++ code, or vcpkg.json file. You can refer to the manifest document on how to create a manifest project.

sylveon commented 3 days ago

@jimwang118 sorry, forgot to push, should be there now

jimwang118 commented 3 days ago

I reproduced this problem locally. But the VS compiler prompts as follows: C++ IntelliSense support for C++20 Modules is currently experimental. Help improve the experience by reporting any issues at https://aka.ms/CppIntelliSenseModules. Affected file 'F:\vcpkg-modules-issue\ConsoleApplication2.ixx'. This should be a compiler problem. You can submit the issue at https://aka.ms/CppIntelliSenseModules.

sylveon commented 3 days ago

the message you see is only for IDE intellisense, e.g. autocomplete and syntax highlighting. the compiler's support is stable. the bug is in vcpkg's msbuild support, which isn't ordered properly in the build pipeline (currently it does scanning > install deps > compiling, when it should do install deps > scaning > compiling)