How do I programmatically determine the path of my source code when running unit tests in Visual Studio Online's hosted build infrastructure.
Why do I want to know this? I want an integration test to run redis-server.exe from the Redis-64 NuGet package so that it can run tests that use Redis.
FWIW, here are the environment variables from the Visual Studio Online build server:
PROCESSOR_ARCHITEW6432=AMD64
COMPUTERNAME=BUILD-0012
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
GTK_BASEPATH=C:\Program Files (x86)\GtkSharp\2.12\
VSSDK140Install=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VSSDK\
VSSDK120Install=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VSSDK\
PROCESSOR_REVISION=2d07
VS100COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
TMP=C:\Users\BUILDG~1\AppData\Local\Temp
TEMP=C:\Users\BUILDG~1\AppData\Local\Temp
LOCALAPPDATA=C:\Users\buildguest\AppData\Local
PUBLIC=C:\Users\Public
ANDROID_HOME=C:\java\androidsdk\android-sdk
M2_HOME=C:\java\maven\apache-maven-3.2.2
JAVA_HOME=C:\java\jdk\jdk1.8.0_25
USERDOMAIN=BUILD-0012
ProgramFiles(x86)=C:\Program Files (x86)
Path=C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Users\VssAdministrator\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\nodejs\;C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\
PROCESSOR_LEVEL=6
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 45 Stepping 7, GenuineIntel
PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files\SharePoint Online Management Shell\;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\PowerShell\Modules\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\PowerShell\Modules\
NUMBER_OF_PROCESSORS=2
CommonProgramFiles=C:\Program Files (x86)\Common Files
VS120COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\
ProgramW6432=C:\Program Files
ProgramFiles=C:\Program Files (x86)
FP_NO_HOST_CHECK=NO
EnableNuGetPackageRestore=True
SystemRoot=C:\Windows
VSSDK110Install=C:\Program Files (x86)\Microsoft Visual Studio 11.0\VSSDK\
CommonProgramW6432=C:\Program Files\Common Files
USERPROFILE=C:\Users\buildguest
VS140COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\
APPDATA=C:\Users\buildguest\AppData\Roaming
ProgramData=C:\ProgramData
ANT_HOME=C:\java\ant\apache-ant-1.9.4
WIX=C:\Program Files (x86)\WiX Toolset v3.7\
XNAGSShared=C:\Program Files (x86)\Common Files\Microsoft Shared\XNA\
VS110COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\
USERNAME=buildguest
PROCESSOR_ARCHITECTURE=x86
OS=Windows_NT
ComSpec=C:\Windows\system32\cmd.exe
ANDROID_NDK_HOME=C:\java\androidsdk\android-ndk-r10d
SystemDrive=C:
windir=C:\Windows
ALLUSERSPROFILE=C:\ProgramData
TF_BUILD_SOURCESDIRECTORY works as documented here in pre-post test scripts.
They are not available in the VSTestRunner activity.
So you should prepare your application using a pre-test script, where you can grab stuff from known build places.
NOTE
The environment variables are available only with later build templates, like TfvcTemplate.12.xaml and GitTemplate.12.xaml. The DefaultTemplate.11.xaml shows only TF_BUILD.
Type C:\a\src into your source code. At least the path is always the same, but I hope there's a better answer.
Related
In order to compile an app with cl cpp compiler in the command line on previous versions of Visual studio I ran the vcvars64.bat script and then compiler worked as expected.
I have recently installed Visual Studio 2019. I have found vcvar64.bat script at the following location: C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build.
But running this script doesn't make cl compiler work. Even simple 3 line cpp files fail compilation with silly errors like "stddef.h" file not found. Compiler works as expected if you are using it from IDE.
What do you need to do to make VS2019 cpp compiler work in command line?
In my visual studio 2019 installation stddef.h is found in C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt. vcvars.bat should be adding this path to the INCLUDE environment variable.
Running the following might provide some hints:
set VSCMD_DEBUG=3
vcvars64.bat > out.txt
In my installation searching out.txt for call :GetWin10SdkDir comes to the section where the bat file is searching for a SDK directory. Hopefully there will be some error messages in there somewhere.
For reference these are the additional environment variables set by a working call to vcvars64.bat on my machine:
CommandPromptType=Native
DevEnvDir=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\
ExtensionSdkDir=C:\Program Files (x86)\Microsoft SDKs\Windows Kits\10\ExtensionSDKs
Framework40Version=v4.0
FrameworkDir=C:\WINDOWS\Microsoft.NET\Framework64\
FrameworkDIR64=C:\WINDOWS\Microsoft.NET\Framework64
FrameworkVersion=v4.0.30319
FrameworkVersion64=v4.0.30319
HTMLHelpDir=C:\Program Files (x86)\HTML Help Workshop
INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.24.28314\ATLMFC\include;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.24.28314\include;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt
LIB=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.24.28314\ATLMFC\lib\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.24.28314\lib\x64;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.17763.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.17763.0\um\x64;
LIBPATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.24.28314\ATLMFC\lib\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.24.28314\lib\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.24.28314\lib\x86\store\references;C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.17763.0;C:\Program Files (x86)\Windows Kits\10\References\10.0.17763.0;C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319;
NETFXSDKDir=C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\
Path=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.24.28314\bin\HostX64\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\VC\VCPackages;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\bin\Roslyn;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Team Tools\Performance Tools\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Team Tools\Performance Tools;C:\Program Files (x86)\Microsoft Visual Studio\VS15Preview\Common\VSPerfCollectionTools\vs2019\\x64;C:\Program Files (x86)\Microsoft Visual Studio\VS15Preview\Common\VSPerfCollectionTools\vs2019\;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\;C:\Program Files (x86)\HTML Help Workshop;C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64;C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\\MSBuild\Current\Bin;C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\Tools\;
Platform=x64
UCRTVersion=10.0.17763.0
UniversalCRTSdkDir=C:\Program Files (x86)\Windows Kits\10\
VCIDEInstallDir=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\VC\
VCINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\
VCToolsInstallDir=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.24.28314\
VCToolsRedistDir=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Redist\MSVC\14.24.28127\
VCToolsVersion=14.24.28314
VisualStudioVersion=16.0
VS160COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\Tools\
VSCMD_ARG_app_plat=Desktop
VSCMD_ARG_HOST_ARCH=x64
VSCMD_ARG_TGT_ARCH=x64
VSCMD_VER=16.4.2
VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\
WindowsLibPath=C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.17763.0;C:\Program Files (x86)\Windows Kits\10\References\10.0.17763.0
WindowsSdkBinPath=C:\Program Files (x86)\Windows Kits\10\bin\
WindowsSdkDir=C:\Program Files (x86)\Windows Kits\10\
WindowsSDKLibVersion=10.0.17763.0\
WindowsSdkVerBinPath=C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\
WindowsSDKVersion=10.0.17763.0\
WindowsSDK_ExecutablePath_x64=C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\
WindowsSDK_ExecutablePath_x86=C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\
__DOTNET_ADD_64BIT=1
__DOTNET_PREFERRED_BITNESS=64
If all else fails a re-install of visual studio is likely to fix the issue.
First of all ,you should install either Visual Studio and the optional Desktop development with C++ workload, or the command-line Build Tools for Visual Studio.
Before you can build a C or C++ program on the command line, you must
verify that the tools are installed, and that you can access them from
the command line. Visual C++ has complex requirements for the
command-line environment to find the tools, headers, and libraries it
uses. You can't use Visual C++ in a plain command prompt window
without doing some preparation. Fortunately, Visual C++ installs
shortcuts for you to launch a developer command prompt that has the
environment set up for command line builds. Unfortunately, the names
of the developer command prompt shortcuts and where they're located
are different in almost every version of Visual C++ and on different
versions of Windows.
A developer command prompt shortcut automatically sets the correct
paths for the compiler and tools, and for any required headers and
libraries. You must set these environment values yourself if you use a
regular Command Prompt window.
If you get an error such as "'cl' is not recognized as an internal or external command, operable program or batch file," error C1034, or error LNK1104 when you run the cl command, then either you are not using a developer command prompt, or something is wrong with your installation of Visual C++.
I suggest you could try to use Developer Command Prompt for VS directly. Please open the Start menu and choose All apps. Scroll down and open the Visual Studio folder (not the Visual Studio application). Choose Developer Command Prompt for VS to open the command prompt window.
For more details I suggest you could refer to the DOC:Walkthrough: Compiling a Native C++ Program on the Command Line
I'm still new to c++ and directX , what I'm trying to do is to include d3d11 to my project , after some research I ended up finding that I need to download windowsSDK 8.1 and then I go to Settings -> Compiler -> Search directories , and Add directories to the compiler and the linker
but when I installed the sdk I couldn't find :
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\include
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\lib
or :
C:\Program Files (x86)\Microsoft SDKs\Windows Kits\8.1\include
C:\Program Files (x86)\Microsoft SDKs\Windows Kits\8.1\lib
C:\Program Files (x86)\Microsoft SDKs\Windows Kits\8.1\bin
in the :
C:\Program Files (x86)\Microsoft SDKs\Windows Kits
there is only folder ( 10 )
and in the :
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\
there is only folder call ( bin )
I dont know if I'm doing something wrong or Microsoft change the directories or something .
Generally you select which Windows SDK to use by editing the Visual C++ project properties and setting the General -> "Windows SDK Version" property.
If you are using some makefile-based build solution, the paths you want to use are actually:
C:\Program Files (x86)\Windows Kits\8.1\Include\shared
C:\Program Files (x86)\Windows Kits\8.1\Include\um
C:\Program Files (x86)\Windows Kits\8.1\Include\winrt
C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86
-or-
C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x64
Or if using the Windows 10 SDK (which does in fact support Win32 desktop applications targeting Windows Vista SP2 or later) and assuming you have the latest Windows 10 Fall Creators Update (16299) installed:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0\shared
C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0\um
C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0\winrt
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\um\x86
-or-
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\um\x64
As you are new to Direct3D, I'd recommend using the directx-vs-templates with VS 2013, VS 2015, or VS 2017. Also see DirectX Tool Kit for DX11.
I am trying to build a code using VS 2008 professional and windows CE 6.0 SDK.
I was getting one error fatal error C1083: Cannot open include file: 'crtdbg.h': No such file or directory. I have included the following paths in the Tools ->options->VC++ Directories->Include
files$(VCInstallDir)ce\include
C:\Program Files\Windows CE Tools\SDKs\Toradex_CE600\include\ARMv4I
C:\Program Files\Windows CE Tools\SDKs\Toradex_CE600\include
$(VCInstallDir)ce\atlmfc\include
$(VSInstallDir)SmartDevices\SDK\SQL Server\Mobile\v3.0
Tools ->options->VC++ Directories->Include files$(VCInstallDir)ce\Library filesC:\Program Files\Windows CE Tools\SDKs\Toradex_CE600\lib\ARMv4I
$(VCInstallDir)ce\atlmfc\lib\ARMv4I
$(VCInstallDir)ce\lib\ARMv4I
Tools ->options->VC++ Directories->Include files$(VCInstallDir)ce\source filesC:\Program Files\Microsoft Visual Studio 9.0\VC\include
$(VCInstallDir)ce\atlmfc\src\atl
$(VCInstallDir)ce\atlmfc\src\mfc
$(VCInstallDir)ce\crt\src
Also the solution->properties->Debug source files has the following paths.
c:\Program Files\Microsoft Visual Studio 9.0\VC\crt\src\
c:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\src\mfc\
c:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\src\atl\
c:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\
C:\Program Files\Microsoft Visual Studio 9.0\VC\include
This file is used in my startup project. My solution has 10 projects(MFC static library). 9 out of 10 are successfully compiled. Just this project is giving this error. So included the path C:\Program Files\Microsoft Visual Studio 9.0\VC\crt\src in that projects additional directories. Now its giving me this error.
Can you please help me.
I am trying to migrate a project from VS2010 to VS2017. The project utilizes Makefile (for a number of reasons). So I compile with CL.exe
The problem is that CL.exe from VS2017 compiles my sources as if the target platform is Windows 10 and tries including headers from UCRT:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\crtdefs.h(10): fatal error C1083: Cannot open include file: 'corecrt.h': No such file or directory
This file (corecrt.h) is part of the Windows 10 SDK and UCRT.
I get this problem even if I change the environment to use Windows 8.1 SDK instead of 10:
INCLUDE="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\atlmfc\include;C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um;C:\Program Files (x86)\Windows Kits\8.1\Include\shared;C:\Program Files (x86)\Windows Kits\8.1\Include\um;C:\Program Files (x86)\Windows Kits\8.1\Include\winrt;C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\crt\src\stl;"
LIB="C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\ATLMFC\lib\x64;C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\lib\x64;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\Lib\um\x64;C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x64;C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\lib\x64\store;"
There must be some switch or some other way to tell CL.exe that I want to use Windows 8.1 SDK or that I want to target Windows 7/8.x.
Does anybody knows how this works?
In my Visual Studio 2017 RC Professional installation, Intellisense cannot seem to find some methods like rand, but also atof or the struct time_t. However, my code is compiling and running correctly.
I have tried running devenv /resetSettings and even a complete reinstallation of VS 2017 to no avail.
I suspect it may be something to do with some environment variable not being set correctly, however I do not know which variables might be responsible. In my project properties under VC++ directories, my Include Directories is set to $(VC_IncludePath);$(WindowsSDK_IncludePath);, and the contents of these variables evaluates to:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.24911\include
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.24911\atlmfc\include
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\VS\include
C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\VS\UnitTest\include
C:\Program Files (x86)\Windows Kits\8.1\Include\um
C:\Program Files (x86)\Windows Kits\8.1\Include\shared
C:\Program Files (x86)\Windows Kits\8.1\Include\winrt