Visual Studio 2019 Windows SDK executable path macro has multiple paths - visual-studio

I'm trying to use $(WindowsSDK_ExecutablePath_x64) in my C++ project post build events to copy some files. However, it contains two paths instead of one. I can't seem to be able to find how to use the first path (not the .Net one):
C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64
I'd like to do something like copy /Y $(WindowsSDK_ExecutablePath_x64)\bin\file.ext destination in my post build events. How can I do this? I'm using VS 2019 and have the latest Windows SDK installed.

I ended up using the following:
$(WindowsSdkDir)bin\$(TargetPlatformVersion)\x64\dxil.dll

Related

Visual Studio 2022: Cannot open include file: 'ctype.h'

I've got the infamous error message in C++ build: "Cannot open include file: 'ctype.h'". I know a similar question was already asked multiple times, but my case seems different because I am using the latest Visual Studio 2022 and seems to behave differently.
I have a bunch of existing C++ projects, they use plain 32-bit Windows API with DirectX 6, and I used VC++ build tools 2015 and Windows SDK 8.1 to compile it without any issues in previous versions of Visual Studio. Everything was fine in Visual Studio 2019, no special setup was needed, until I uninstalled it and installed Visual Studio 2022.
Now I can open my solutions, it nicely shows they are using C++ build tools 2015, which I installed together with VS2022, and the solutions also shows correctly that they use Windows 8.1 SDK. But Windows 8.1 SDK is not present in VS2022 installation, I installed it separately. I also tried to "repair" VS2022 installation, but that only deleted all my UI preferences, but not fixed anything in build. Also, I tried to reinstall Windows 8.1 SDK, but it said it is already OK.
When looking to Visual Studio, I can't see any place where I can set default include and lib directories, I can only list what is being used right now. VS2022 shows this list:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include
C:\Program Files\Windows Kits\10\Include\10.0.10240.0\ucrt
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
The actual error message I receive is this:
c:\program files (x86)\windows kits\8.1\include\um\winnt.h(31): fatal error C1083: Cannot open include file: 'ctype.h': No such file or directory
So it says that winnt.h from windows kits 8.1 cannot find ctype.h. And yes, there is no ctype.h in that folder or anywhere around, I can see it only in C:\Program Files\Microsoft Visual Studio\2022\Professional\SDK\ScopeCppSDK\vc15\SDK\include\ucrt
which I think is the folder with VC++ 2015 build tools. So this seems correct, but I am wondering why this folder is not a part of default include directories when VC++ 2015 build tools are set in project settings. Because it seems that VS2022 is correctly picking my Windows 8.1 SDK, but not picking correctly the older C++ compiler.
When I try to add the folder where ctype.h resides to include folders, I receive another type of errors saying that other files are incompatible with these include files. Of course, this system of directories needs to be in sync. So please what is the correct way of using this?
Also, I tried to switch the VC++ build tools to 2022 version. Unfortunately, that also does not fix the issue. And Windows 10 SDK is not installed, the software wants to stay compatible with older Windows, so I don't need it.
I found a bug report which is related: https://developercommunity.visualstudio.com/t/windows-81-sdk-1/151682
Although Microsoft staff declined to accept it as a bug, it is happening for me as well. When I install only Windows 8.1 SDK, no project can be compiled with it. I even tried to create a new Windows API project in VS2022, the project was created, but failed to compile with the same error.
So I tried to install Windows 10 SDK (from VS2022 installed, but that is probably not important) and this added some missing files which now help to compile Windows 8.1 SDK projects. Problem seems to be solved, my old C++ code can now be compiled with Windows 8.1 SDK and both C++ build tools 2015 and 2022.

Where can I find the Windows header files

Sometimes in my research into Microsoft functions, I'll see the name of a constant and perhaps a reference to a header file - like winuser.h. I don't often need to refer to them but when I do, I wind up spending some time Googling to find out where those files are. With this question, I can hopefully come to the answer right away. The question, as the title says, is: Assuming I've installed Visual Studio or the SDK, where in the file directory structure on a windows machine can I find the basic windows header files, like windows.h and winuser.h?
First you need to install Visual Studio or the Windows SDK. I'd give URLs here but they change with every new version of windows. The header files could be in
C:\Program Files\Microsoft SDKs\Windows\vX.X\Include
C:\Program Files (x86)\Microsoft SDKs\Windows\vX.X\Include
(where vX.X reflects the version number)
Update - May 2020
I'm on a new machine and installed VS2019 and the WindowsSDK and here are the new locations:
C:\Program Files (x86)\Microsoft Visual
Studio\2019\Professional\SDK\ScopeCppSDK\vc15\SDK\include\um
C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um
I do not see any includes in the 'Program Files' folders.

Visual studio 'xsd' command: file path

The command 'xsd' in the Visual Studio (2010) command window is not fiding my file.
Tried full path 'c:\...\etc...', tried path from project folder, tried any sub path of the full path, tried only the file name (as shown on any example in the web of the usage of the tool).
The file is inside the project inside a subfolder, like "project\schema\mySchema.xsd".
Command used
>Tools.Shell xsd <path\>myfile.xsd /classes
returns:
The operation could not be completed. System could not find specified file.
What work around can I make, how should I properly use the tool? (Am I using it wrongly?)
To find XSD.exe these days, go to:
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2
Tools\xsd.exe
Step by step:
Go to C:\Program Files (x86)\Microsoft SDKs\Windows\
Click latest version (e.g. v10.0A)
Click Bin
Select latest .NET Version e.g. NETFX 4.7.2 Tools
There is xsd.exe
When you launch the shortcut that opens the Visual Studio Command Prompt you execute a batch file that set some important string inside the PATH environment variable. These strings contain the folder names where the XSD tool is located.
The shortcuts are located in this folder on my dev PC with Visual Studio 2013
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts
The shortcut that opens the Command Prompt for Visual Studio x86 Native Tools is something like this
%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"" x86
So, unless your installation is damaged you should be able to find the correct command in the relative directory of your Visual Studio 2010 install.

Why are windows definitions missing on msvc++

I have not been coding in MSVC lately. I have been assigned an old code that has lots of errors but most of the missing definitions are of Windows API.
For example, LPHANDLER_FUNCTION_EX is not defined and is causing C2061 compile error. But I already included Winsvc.h or Windows.h. I know that this is just a definition, I checked my C:\Program Files\Microsoft SDK\ for the definition can be found on the Winsvc.h. So I added the SDK on the directory list (Tools > Options > Directory Tab).
I also downloaded the Windows SDK February 2003 update which is the last version that works with msvc6. (ref)
Just for completeness, My PC is Windows XP SP3. Microsoft Visual C++ Enterprise Edition with SP6 installed. I also installed the Windows SDK February 2003 update.
Any ideas?
I was able to solve this by fixing the order of the include directory via Tools > Options > Directory Tab.
Before the VC98 folder was on top of the SDK.
1st C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE
2nd C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE
3rd C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE
4th C:\Program Files\Microsoft SDK\include
Just place the SDK directory to the top of the list and it works.
The suggestion to use /E option by jamesdlin was helpful. Also I set the /E option in the Project Settings > Library Tab > Project Option textbox. The log would be placed in the .plg file inside the project folder.
This would also apply to missing lib file. Set the directory to the SDK directory for library.

Task could not find "AL.exe" using the SdkToolsPath

I have this problem tring to build one solution
Task could not find "AL.exe" using the SdkToolsPath "C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\" or the registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A". Make sure the SdkToolsPath is set and the tool exists in the correct processor specific location under the SdkToolsPath and that the Microsoft Windows SDK is installed
I know there is a similar question, but the aswer didn't work for me
In the same computer a can build other solutions in Net 4 without any problem, so don't understand
I'm using:
Windows XP Professional SP3
Visual Web Developer 2010 Express
Easiest thing to do is copy al.exe
from
C:\Program Files\Microsoft SDKs\Windows\v7.1\bin\NETFX 4.0 Tools\
(For Windows 10 from
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools)
to
C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\
As I got this issue in VS2019 after a fresh install of both Windows and Visual Studio 2019 I thought it might be good to share:
Installing Microsoft.Net.Component.4.7.2.SDK from the Visual Studio installer fixed it for me!
Do you have any resource files in your project? Try to delete all of them and build your project again.
I've got exact the same error and after deleting the resource files (*.hrsx) my build worked again.
Maybe it helps.
I am using VS2019, this way works for me:
Add a system env variable TargetFrameworkSDKToolsDirectory
like this:
TargetFrameworkSDKToolsDirectory=C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools

Resources