Win10SysProgBookSamples icon indicating copy to clipboard operation
Win10SysProgBookSamples copied to clipboard

Unable to compile examples in Chapter 2

Open gituser20091 opened this issue 3 years ago • 3 comments

Hello, I am using VS2019 and VS2022. In both of those environments whenever I try to build any of the examples of Chapter02 I get the following error message:

Rebuild started... 1>------ Rebuild All started: Project: BasicSharing, Configuration: Debug Win32 ------ 1> \Win10SysProgBookSamplesP1\Chapter02\BasicSharing\BasicSharing.vcxproj(232,5): error : This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ....\packages\wtl.10.0.9163\build\native\wtl.targets. 1>Done building project "BasicSharing.vcxproj" -- FAILED. ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

I get the same error for the Debug Win64 configuration.

I've tried a number of things to correct the problem, most of them found on stackoverflow but, I have been unsuccessful.

For the record, my knowledge of C++ is quite deficient. I suspect the solution is simple but, it has eluded me so far.

I hope it is ok to report this as an issue since I may not be the only one who has experienced problems building the examples.

Also, just in case this may be important, the samples are on a network drive. I mention this because I've noticed that VS can get "picky" about code that is not on the local hard drive.

Thank you for your help

gituser20091 avatar Dec 20 '21 09:12 gituser20091

Here are some steps that helped me overcome this issue:

  • Right click on the solution in the solution explorer and select Restore NuGet Packages
  • Open the vcxproj files in a text editor and replace all occurences of the string ..\..\packages to ..\packages.

For some reason it tries to locate the packages downloaded in the wrong folder.

mihaly044 avatar Jan 04 '22 12:01 mihaly044

@mihaly044 thank you so much!

mkamran67 avatar Apr 13 '22 06:04 mkamran67

If above methods did not help could be checked:

Right click on the project name to load it in Solution Explorer and select the Manage NuGet Packages, then select the Update tab to see packages that have an available updates from the selected Package source.

Note that if after, there appears an error like "The missing file is "....\packages\wtl.10.0.9163\build\native\wtl.targets", remove these lines from .vcxproj file:

<Import Project="packages\wtl.10.0.9163\build\native\wtl.targets" Condition="Exists('packages\wtl.10.0.9163\build\native\wtl.targets')" />
<Error Condition="!Exists('packages\wtl.10.0.9163\build\native\wtl.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\wtl.10.0.9163\build\native\wtl.targets'))" />

On the Tools menu select the Options, then select General under the NuGet Package Manager for the Package Restore. Then select exactly the Packages.config for Default package management under Package Management and set both options under the Package Restore.

If there generates MSB8020 error, then right click on the project name, select Properties and under the Solution configurations select General, then set Visual Studio 20xx (v14x) for Platform Toolset,- on my case I set Visual Studio 2019 (v142)

shalala66 avatar Oct 29 '23 12:10 shalala66