Skip to content

[vcpkg] vcpkg fails if the path contains []s (applocal.ps1 tries to copy to C:\windows\SysWOW64\windowspowershell\v1.0\ ) #14339

Open
@erri120

Description

@erri120

Describe the bug
vcpkg tries to copy dlls to C:\windows\SysWOW64\windowspowershell\v1.0\:

Scanning dependencies of target U1
[ 50%] Building CXX object CMakeFiles/U1.dir/main.cpp.obj
main.cpp
[100%] Linking CXX executable U1.exe
Split-Path : Cannot bind argument to parameter 'Path' because it is null.
At M:\Projects\vcpkg\scripts\buildsystems\msbuild\applocal.ps1:40 char:39
+     $baseTargetBinaryDir = Split-Path $baseBinaryPath -parent
+                                       ~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Split-Path], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.SplitPathCo 
   mmand
 
Split-Path : Cannot bind argument to parameter 'Path' because it is null.
At M:\Projects\vcpkg\scripts\buildsystems\msbuild\applocal.ps1:58 char:35
+     $targetBinaryDir = Split-Path $targetBinaryPath -parent
+                                   ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Split-Path], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.SplitPathCo 
   mmand
 
Copy-Item : Access to the path 'C:\windows\SysWOW64\windowspowershell\v1.0\opencv_highguid.dll' is denied.
At M:\Projects\vcpkg\scripts\buildsystems\msbuild\applocal.ps1:29 char:9
+         Copy-Item "$SourceDir\$targetBinaryName" $targetBinaryDir
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (M:\Projects\vcp...cv_highguid.dll:FileInfo) [Copy-Item], Unauthorized 
   AccessException
    + FullyQualifiedErrorId : CopyFileInfoItemUnauthorizedAccessError,Microsoft.PowerShell.Commands.CopyItemCommand
 
Copy-Item : Access to the path 'C:\windows\SysWOW64\windowspowershell\v1.0\opencv_imgcodecsd.dll' is denied.
At M:\Projects\vcpkg\scripts\buildsystems\msbuild\applocal.ps1:29 char:9
+         Copy-Item "$SourceDir\$targetBinaryName" $targetBinaryDir
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (M:\Projects\vcp..._imgcodecsd.dll:FileInfo) [Copy-Item], Unauthorized 
   AccessException
    + FullyQualifiedErrorId : CopyFileInfoItemUnauthorizedAccessError,Microsoft.PowerShell.Commands.CopyItemCommand
 
Copy-Item : Access to the path 'C:\windows\SysWOW64\windowspowershell\v1.0\opencv_cored.dll' is denied.
At M:\Projects\vcpkg\scripts\buildsystems\msbuild\applocal.ps1:29 char:9
+         Copy-Item "$SourceDir\$targetBinaryName" $targetBinaryDir
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (M:\Projects\vcp...pencv_cored.dll:FileInfo) [Copy-Item], Unauthorized 
   AccessException
    + FullyQualifiedErrorId : CopyFileInfoItemUnauthorizedAccessError,Microsoft.PowerShell.Commands.CopyItemCommand
 
[100%] Built target U1

Build finished

The build itself is successful, the libraries were linked but vcpkg for some reason wants to copy the dlls to this windows path instead of the output path. Running the resulting exe will get you

The code execution cannot proceed because SOMELIB was not found. Reinstalling the program may fix this problem.

Environment

  • Windows
  • Fails with both VS and CLion

To Reproduce

  1. Create a new CMake project
  2. Install some packages (opencv in my case)
  3. Code
  4. Build
  5. Error

Expected behavior
No failure. Don't even understand why vcpkg would want to copy the files to this directory. Should copy files to the output directory, no?

CMakeLists.txt:

cmake_minimum_required(VERSION 3.17)
project(U1)
set(CMAKE_CXX_STANDARD 14)

find_package(OpenCV REQUIRED)
add_executable(U1 main.cpp)
target_link_libraries(U1 ${OpenCV_LIBS})

Metadata

Metadata

Labels

category:vcpkg-bugThe issue is with the vcpkg system (including helper scripts in `scripts/cmake/`)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions