Skip to content
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

Portfiles and portfile functions cannot find msbuild; emit Error code: no such file or directory #42689

Open
sharadhr opened this issue Dec 13, 2024 · 0 comments

Comments

@sharadhr
Copy link
Contributor

Describe the bug
I have been writing a custom overlay port to install a project that is built with MSBuild (WinFSP). When I run vcpkg_msbuild_install(...) in the portfile, I receive the following error:

CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:127 (message):
    Command failed: msbuild W:/project/linux/lib/vcpkg/buildtrees/winfsp/x64-mingw-static-rel/build/VStudio/winfsp_dll.vcxproj /p:Configuration=Release /p:ForceImportAfterCppProps=W:/project/linux/lib/vcpkg/buildtrees/winfsp/x64-mingw-static/vcpkg_msbuild.props /p:ForceImportAfterCppTargets=W:/project/linux/lib/vcpkg/buildtrees/winfsp/x64-mingw-static/vcpkg_msbuild.targets /t:Rebuild /p:UseMultiToolTask=true /p:MultiProcMaxCount=17 /p:EnforceProcessCountAcrossBuilds=true /m:17 -maxCpuCount:17 /p:Platform=x64 /p:PlatformTarget=x64 /p:PlatformToolset=external /p:WindowsTargetPlatformVersion= /p:VcpkgApplocalDeps=false /p:VcpkgManifestInstall=false /p:VcpkgManifestEnabled=false /p:VcpkgEnabled=false /p:VcpkgTriplet=x64-mingw-static /p:VcpkgInstalledDir=W:/project/build/windows-x64-release/vcpkg_installed
    Working Directory: W:/project/linux/lib/vcpkg/buildtrees/winfsp/x64-mingw-static-rel
    Error code: no such file or directory
    See logs for more information:

Call Stack (most recent call first):
...

(There is no log file produced).

To minimise this I tried directly running vcpkg_execute_required_process(COMMAND msbuild.exe WORKING_DIRECTORY ${SOURCE_PATH}) in the portfile, and I still see Error code: no such file or directory. I suspect vcpkg cannot find msbuild in its PATH as it sanitises the environment, and this error is emitted. I see similar outputs when I try to run msbuild in a non-Developer PowerShell or non-Developer Command Prompt.

Below is my triplet that uses a custom toolchain (LLVM-MinGW):

set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_BUILD_TYPE release)

set(VCPKG_ENV_PASSTHROUGH
	LLVM_ARCH
	LLVM_MINGW_SYSROOT
	BUILD_WITH_LTO
)

set(VCPKG_CMAKE_SYSTEM_NAME MinGW)

set(DYNAMIC_PORTS
	"winfsp"
)

if("${PORT}" IN_LIST DYNAMIC_PORTS)
	set(VCPKG_LIBRARY_LINKAGE dynamic)
endif()

set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../../cmake/toolchains/clang-mingw.cmake")
set(VCPKG_LOAD_VCVARS_ENV ON)

And below are the overlay portfile and vcpkg.json for WinFSP:

portfile.cmake

vcpkg_from_github(
	REPO winfsp/winfsp
	REF "v${VERSION}"
	SHA512 f514541e2ebd221ff13074592c0d75fc0fe22b685292e1f65d3e24668b7ac93cf03107dad89b1014db2b358c1280e4287e983538d482b0a2b441d18d16729fb0
	OUT_SOURCE_PATH SOURCE_PATH
)

vcpkg_msbuild_install(
	SOURCE_PATH "${SOURCE_PATH}"
	PROJECT_SUBPATH "build/VStudio/winfsp_dll.vcxproj"
	PLATFORM ${VCPKG_TARGET_ARCHITECTURE}
)

vcpkg.json

{
  "name": "winfsp",
  "version": "2.0",
  "description": [
    "Windows File System Proxy - FUSE for Windows",
    "WinFsp enables developers to write their own file systems (i.e. \"Windows drives\") as user mode programs and without any knowledge of Windows kernel programming. It is similar to FUSE (Filesystem in Userspace) for Linux and other UNIX-like computers."
  ],
  "homepage": "https://winfsp.dev/",
  "license": "GPL-3.0-or-later",
  "supports": "windows | mingw",
  "dependencies": [
    {
      "name": "vcpkg-msbuild",
      "host": true
    }
  ]
}

Environment

  • OS: Windows

To Reproduce
Steps to reproduce the behaviour:

  1. Install the above custom overlay portfiles.
  2. Use any custom chain-loaded toolchain.
  3. See the above failure.

Expected behaviour
Naturally, I expect vcpkg to set up VsDevCmd.bat that sets up the environment and the PATH before launching msbuild.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant