Docker not running .exe file - c++

I have a question regarding dockerizing C/C++ project. I am using visual studio compiler image because I have a lot of environment trouble with running MinGW compiler.
I confirmed project using visual studio compiler image and building solution perfectly, but I'm seeing problem with actually running generated .exe file in docker container environment.
Following is my dockerfile code :
# escape=`
# Copyright (C) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license. See LICENSE.txt in the project root for license information.
ARG FROM_IMAGE=microsoft/dotnet-framework:3.5-sdk-windowsservercore-1709
FROM ${FROM_IMAGE}
# Reset the shell.
SHELL ["cmd", "/S", "/C"]
# Set up environment to collect install errors.
COPY Install.cmd C:\TEMP\
ADD https://aka.ms/vscollect.exe C:\TEMP\collect.exe
# Install Node.js LTS
ADD https://nodejs.org/dist/v8.11.3/node-v8.11.3-x64.msi C:\TEMP\node-install.msi
RUN start /wait msiexec.exe /i C:\TEMP\node-install.msi /l*vx "%TEMP%\MSI-node-install.log" /qn ADDLOCAL=ALL
# Download channel for fixed install.
ARG CHANNEL_URL=https://aka.ms/vs/15/release/channel
ADD ${CHANNEL_URL} C:\TEMP\VisualStudio.chman
# Download and install Build Tools for Visual Studio 2017 for native desktop workload.
ADD https://aka.ms/vs/15/release/vs_buildtools.exe C:\TEMP\vs_buildtools.exe
RUN C:\TEMP\Install.cmd C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
--channelUri C:\TEMP\VisualStudio.chman `
--installChannelUri C:\TEMP\VisualStudio.chman `
--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended`
--installPath C:\BuildTools
# Execute commands once container runs
# Build solution using MSVC
ENTRYPOINT C:\BuildTools\Common7\Tools\VsDevCmd.bat &&
I copied it from microsoft official website here : https://devblogs.microsoft.com/cppblog/using-msvc-in-a-docker-container-for-your-c-projects/
and following is my output
C:\Users\cshim31\smarts-pxie-executive>docker run -v C:\Users\cshim31\smarts-pxie-executive:c:\smarts-pxie-executive -it buildtools2017native:2017 msbuild C:\smarts-pxie-executive\Project4.sln /p:Configuration=Debug /p:Platform=x64
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.0
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 3/10/2021 6:07:46 PM.
Project "C:\smarts-pxie-executive\Project4.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
Building solution configuration "Debug|x64".
Project "C:\smarts-pxie-executive\Project4.sln" (1) is building "C:\smarts-pxie-executive\Project4.vcxproj" (2) on node 1 (default targets).
InitializeBuildStatus:
Creating "x64\Debug\Project4.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
All outputs are up-to-date.
Link:
All outputs are up-to-date.
Project4.vcxproj -> C:\smarts-pxie-executive\x64\Debug\Project4.exe
FinalizeBuildStatus:
Deleting file "x64\Debug\Project4.tlog\unsuccessfulbuild".
Touching "x64\Debug\Project4.tlog\Project4.lastbuildstate".
Done Building Project "C:\smarts-pxie-executive\Project4.vcxproj" (default targets).
Done Building Project "C:\smarts-pxie-executive\Project4.sln" (default targets).
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:01.12
C:\Users\cshim31\smarts-pxie-executive>
After building, it instantly terminated without printing out program output.
Instead, I tried going into docker environment and running .exe by myself.
and following is output :
C:\smarts-pxie-executive\x64\Debug>Project4.exe
C:\smarts-pxie-executive\x64\Debug>
it didn't print out error messages. It works perfectly fine when I opened .exe file on local computer. I am not sure how I should resolve problem since there isn't error message that I can see and fix.

I had the same issue with a Rust executable on a Docker image based on windows/servercore:ltsc2019. I used Dependency Walker to open the executable and saw that it depended on vcruntime140.dll. Then after downloading and installing the Visual C++ 2015 Redistributable package within the Docker container, my executable ran correctly.

Related

CMake can't get the value of VCTargetsPath when generating for UWP

I'm trying to use CMake to build a Universal Windows App, but I get the following build error (latest Visual Studio 2019 and Windows 10 SDK are installed):
› cmake -B. -H<my source dir> -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.
CMake Error at CMakeLists.txt:3 (project):
Failed to run MSBuild command:
C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe
to get the value of VCTargetsPath:
Microsoft (R) Build Engine version 16.5.1+4616136f8 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 5/16/2020 9:52:00 PM.
Project "C:\test\CMakeFiles\3.17.2\VCTargetsPath.vcxproj" on node 1 (default targets).
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(777,5): error : The OutputPath property is not set for project 'VCTargetsPath.vcxproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' Platform='x64'. You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project. [C:\test\CMakeFiles\3.17.2\VCTargetsPath.vcxproj]
Done Building Project "C:\test\CMakeFiles\3.17.2\VCTargetsPath.vcxproj" (default targets) -- FAILED.
Build FAILED.
"C:\test\CMakeFiles\3.17.2\VCTargetsPath.vcxproj" (default target) (1) ->
(_CheckForInvalidConfigurationAndPlatform target) ->
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(777,5): error : The OutputPath property is not set for project 'VCTargetsPath.vcxproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' Platform='x64'. You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project. [C:\test\CMakeFiles\3.17.2\VCTargetsPath.vcxproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.07
Exit code: 1
-- Configuring incomplete, errors occurred!
What does that mean? I've also tried to specify the exact Windows SDK version for CMAKE_SYSTEM_VERSION, but no luck.
I solved the problem. I did many things, therefore I cannot tell which one exactly solved the problem. But try the following.
From VisualStudio Installer app, click Modify and install C++ Universal Windows Platform support for v142 build tools (ARM64) individual component.

build issue for cucumber cpp in windows and with visual studio

I am trying to setup an environment for cucumber cpp in windows 10 and with visual studio. While trying to build the whole solution, I am facing build issues with GTest component
My current environment is as follow
OS: Windows 10
Visual Studio Community Edition 2017
CMake Version:3.14.3
Ruby Version: 2.5.5p157 (2019-03-15 revision 67260) [x64-mingw32]
Boost Library Version: 1.69.0
I followed the steps mentioned in Readme.md
Building Cucumber-Cpp with tests and samples:
# Download test suite
git submodule init
git submodule update
# Create build directory
cmake -E make_directory build
# Generate Makefiles
cmake -E chdir build cmake -DCUKE_ENABLE_EXAMPLES=on -DCMAKE_INSTALL_PREFIX=${prefix} ..
# Build cucumber-cpp and tests
cmake --build build
I am facing build issue with GTest component. Below is the error message
========================================================
Performing build step for 'gtest'
CMake Error at C:/Cucumber/cucumber-cpp/build/gmock/src/gtest-stamp/gtest-build-Debug.cmake:49 (message):
Command failed: 1
'C:/Program Files/CMake/bin/cmake.exe' '--build' '.' '--config' 'Debug'
See also
C:/Cucumber/cucumber-cpp/build/gmock/src/gtest-stamp/gtest-build-*.log
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(209,
5): error MSB6006: "cmd.exe" exited with code 1. [C:\Cucumber\cucumber-cpp\build\gtest.vcxproj]
========================================================

Data collector 'Code Coverage' failed to provide initialization information

I'm trying to create a code coverage report using the Build pipeline.
I have added the task of typeVisual Studio code in the build pipeline and have enabled the Code Coverage.
When the build is triggered. I'm getting :
Data collector 'Code Coverage' message: Data collector 'Code Coverage' failed to provide initialization information. Error: System.TypeInitializationException: The type initializer for 'Microsoft.VisualStudio.Diagnostics.Logging.ProfilerInterop' threw an exception. ---> Microsoft.VisualStudio.Diagnostics.Common.InvariantException: Failed to load IntelliTrace Profiler binary or failed to locate functions.
and
---> System.ComponentModel.Win32Exception: The system cannot find the path specified
This is running the tests and all the tests are passed. However I'm not able to view the code coverage report. The report which it has created contains only information about the tests
Any input on where we specify the path will be useful.
You basically need Visual Studio Test Agent for Code Coverage.
There are 2 possible ways to install for this:
Option 1
Install Agents for Visual Studio 2019 on the Build server (download from here, see under Tools for Visual Studio 2019).
In the build pipeline edit the Visual Studio Test Assemblies task. Set Select test platform using to Specific location and set Path to vstest.console.exe to for example C:\Program Files (x86)\Microsoft Visual Studio\2019\TestAgent\Common7\IDE\Extensions\TestPlatform\vstest.console.exe.
Option 2
Add the Visual Studio test platform installer build task to your pipeline. (Add this task before the testing task).
In the Visual Studio Test Assemblies task you have to select Installed by Tools Installer as the Test platform version
Note: in my experience I had some tests who succeeded with option 1, but failed in option2. Sadly I don't have the time to figure out why...
I faced this issue when configuring a build container.
1 To install the Visual Studio 2019 Test Agent, I used Chocolatey
1.2 Install Chocolatey
ENV chocolateyUseWindowsCompression = false
SHELL ["powershell.exe", "-ExecutionPolicy", "Bypass", "-Command"]
RUN Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')); `
[System.Environment]::SetEnvironmentVariable('PATH', "\"${env:PATH};%ALLUSERSPROFILE%\chocolatey\bin\"", 'Machine'); `
choco feature enable -n allowGlobalConfirmation;
1.2 Install the TestAgent with chocolatey
RUN choco install visualstudio2019testagent -y
2. Edit the VSTest task on your pipeline to use a specific location.
In my case, I've installed into the container the VSBuildTools. The VSTest task used the VSBuildTools vstest.console.exe but the execution needs some libraries that are located at the TestAgent folders.
vstestLocationMethod: location
vstestLocation: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\TestAgent\Common7\IDE\Extensions\TestPlatform\vstest.console.exe'
Had a similar problem after updating build agent and adding VS2017 capabilities.
Downloaded (from https://www.opendll.com): microsoft.intellitrace.profiler.dll
Add to folder C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\Extensions\TestPlatform\x64​
Good luck

error: command 'C:\\ Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2

Hi so I was trying to pip install python-ldap using my git bash but at first it told me that i don't have cl.exe so i downloaded the visual studio C++ pack now it's showing this error
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
I never coded with C++ so I'm not sure what the error is. I downloaded the CLI tools for C++ too and I don't think it's because the cl.exe isn't in the path since it found it. Any insights ??
Install Visual C++ 2015 Build Tools from https://go.microsoft.com/fwlink/?LinkId=691126 with default selection.
I know this question was asked years ago, but for future users, I thought of providing an answer for this question. Today I've faced the same problem with the "Microsoft visual studio 2019 build tool."
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
I have come across this issue while trying to install the dependency through anaconda3 cmd in windows OS.
pip install sparse_dot_topn
I have tried different methods suggest in different portals and couldn't resolve this for hours. At the same time, I've ended up installing unnecessary components of the visual studio build tool as well. Finally, I found the problem is associated with the setup tool library, and the problem can be solved through force upgrade to the setup tool package
python -m pip install -U pip setuptools
There doesn't seem to be a valid solution for this error but one workaround is to install the windows binary package from https://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap
In my case, I had to copy or link (using link shell extension) the x64 version of "C Connector" to the x86 folder.
If you can't find the x64 C connector...
Download mysql-installer-web-community-8.0.12.0.msi from their website:
https://dev.mysql.com/downloads/installer/
Run the Installer, and click the Add button on the right, then locate the Connector C 6.1 x64
The C++ Connector has C compatible header files, but hard-linking to it does not work, as explained here: https://dev.mysql.com/downloads/connector/c/
You cannot install the x86 version alongside the x64 version. The installer does not permit this.
Otherwise, Hard-Link the x64 version
Install link shell extension.
Navigate to "C:\Program Files\MySQL\" then right click on "MySQL Connector C 6.1" and click Pick Link Source
Navigate to "C:\Program Files (x86)\MySQL\" and Drop Link As... > Junction
A Junction is a duplicate reference in the file system to a folder. Creating a second junction reclassifies the original folder a junction as well, but they are both authentic references to the same folder, and so, unlike symbolic links, they will work with scripts, because they are real, and are implemented on the file system level.
Then, if the connector you have installed is a different version number and you want to try to force it to work with a non-compatible script, rename it to match the folder mentioned in the error message. For example...
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.15.26726
\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,3,13,'final',0) -D__version__=1.3.13 "-I C:\Program Files (x86)\MySQL\MySQL Connector C 6.1 \include" "-Ic:\program files\python37\include" "-Ic:\program files\python37\include" "-IC:\Program Files (x86)\Microsoft Visu...
Crappy pip code failing to pass variables from the system environment :(
I had a similar issue.
I had installed a 32-bit python interpreter from https://www.python.org/downloads/windows/ mistakenly in my 64-bit windows machine.
Then I downloaded the correct 64-bit interpreter setup and installed it. Then I pointed the Pycharm interpreter path to it.
Then my issue was solved. I hope this will help you...
When I was perusing the internet to find the solution I ran into an adjacent problem:
Python was not found, which I solved by (assuming your python works and is added to PATH) going to Settings > Manage App Execution Aliases and turning off "python". They try installing your package again
Install the C++ build tools from here: https://my.visualstudio.com/Downloads
Search for 'build tools' and download the latest VS build tools installer. Install the C++ build tools (currently it's called "Desktop Development with C++") with the defaults.
What worked for me in the same situation: Except installing VS Build Tools, install whole Visual Studio. Python libs often require C/C++ compiler
I had the same error; although when installing lux-api
What worked for me was downgrading the default python version 3.10 -> 3.9
(ref)
p.s. the error that I had was the following
error: command ...\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX86\\x64\\cl.exe failed with exit code 2
----------------------------------------
ERROR: Failed building wheel for pandas
Failed to build pandas
ERROR: Could not build wheels for pandas, which is required to install pyproject.toml-based projects
I had the similar issue. I was trying to build pandas from source. I figured out that my build tools were not compatible with the source. I had MSVC v142 installed. So I installed the below components and this worked for me:
Windows 10 SDK (10.0.17763.0)
MSVC v141 - VS 2017 C++x64/x86 build tools
These tools can also be installed from cmd, just install visual studio 2019 build tools exe and then run this command in cmd as admin:
vs_buildtools.exe --quiet --wait --norestart --nocache ^
--installPath C:\BuildTools ^
--add "Microsoft.VisualStudio.Workload.VCTools;includeRecommended" ^
--add Microsoft.VisualStudio.Component.VC.v141 ^
--add Microsoft.VisualStudio.Component.VC.v141.x86.x64 ^
--add Microsoft.VisualStudio.Component.Windows10SDK.17763
I also had to install additional tools to make it work correctly:
C++/CLI Support for v141 build tools (14.16)
Once the tools were installed correctly then I had to initialize x64 environment with new installed build tools:
"C:\BuildTools\VC\Auxiliary\Build\vcvars64.bat" -vcvars_ver=14.16 10.0.17763.0
After that I restarted my computer and build pandas again and it was build successfully.

Jenkins windows slave not able build COM dll using command line option

I have configure jenkins on Ubuntu, I am trying to build Windows COM object on windows slave node.
First issue i have face for MSBuild.exe : - I am able to resolve path error after installing MSBuild Plugin and setting MSbuild path in jenkins.
It is giving below error even after setting MSBuild location
" error MSB3411: Could not load the Visual C++ component "VCBuild.exe""
Please see below error statement:
Path To MSBuild.exe: C:\Windows\Microsoft.NET\Framework64\v3.5\MSBuild.exe
Executing the command cmd.exe /C " C:\Windows\Microsoft.NET\Framework64\v3.5\MSBuild.exe /t:Rebuild /p:Configuration=Release C:\Jenkins_Home\workspace\test\test.sln " && exit %%ERRORLEVEL%% from C:\Jenkins_Home\workspace\test
[test] $ cmd.exe /C " C:\Windows\Microsoft.NET\Framework64\v3.5\MSBuild.exe /t:Rebuild /p:Configuration=Release C:\Jenkins_Home\workspace\test\test.sln " && exit %%ERRORLEVEL%%
Microsoft (R) Build Engine Version 3.5.30729.5420
[Microsoft .NET Framework, Version 2.0.50727.5485]
Copyright (C) Microsoft Corporation 2007. All rights reserved.
Build started 11/30/2015 3:34:35 PM.
Project "C:\Jenkins_Home\workspace\test\test.sln" on node 0 (Rebuild target(s)).
Building solution configuration "Release|Win32".
C:\Jenkins_Home\workspace\test\test.sln.cache(64,5): error MSB3411: Could not load the Visual C++ component "VCBuild.exe". If the component is not installed, either 1) install the Microsoft Windows SDK for Windows Server 2008 and .NET Framework 3.5, or 2) install Microsoft Visual Studio 2008.
Done Building Project "C:\Jenkins_Home\workspace\test\test.sln" (Rebuild target(s)) -- FAIL
Same project i am able to build on windows command line, I am not able to figure out issue with jenkins. -- Any suggestion to resolve this issue
I have resolve this issue by setting path in jenkins slave node configuration.
I have taken path environment variable details by running set command on command line where i am able to build this project.
go to http://server_name:8080/computer/win_slave_name/configure and add path as show in image