2

I wiped out an old Windows 10 and replaced it with a new Windows 10 by ISO image.

  1. Before wiping out, I copied the folder of Microsoft Visual Studio 2017 Community Edition on old Windows to an external hard disk:
xcopy /E "C:\Program Files (x86)\Microsoft Visual Studio" D:\
  1. Now after reinstalling Windows 10, I copied the VS 2017 folder from external the hard disk to the C:\Program Files (x86)\ folder of new operating system.

  2. I did so to avoid having to download VS 2017 again on new OS.


The problem is other software, like Qt Creator, cannot auto-detect the VS C/C++ compilers. I guess that's because the VS 2017 isn't added to path.


The questions are:

  • What path should I add to system path in order to VS 2017 to be auto-detected by other software like Qt Creator?
  • Is there any script which I can run to automatically integrate the VS 2017 to the rest of the operating system.
Megidd
  • 7,089
  • 6
  • 65
  • 142
  • 2
    I dont`t think this was a good idea. With your installation there should come a visual studio- installer you can use, which should install all dependencies and adjust the correct environment variables. I would not recommend copy pasting installed programs, beacuse these maybe install dependencies where you wouldn't search them – RoQuOTriX Oct 14 '19 at 08:39
  • @RoQuOTriX There is an installer in `C:\Program Files (x86)\Microsoft Visual Studio\Installer` named `vs_installer`. Let me try it. – Megidd Oct 14 '19 at 08:41
  • copy this installer and remove the copied files. The installer should download the correct and actual files – RoQuOTriX Oct 14 '19 at 08:42
  • That's not recommended way to just copy the content of `C:\Program Files (x86)\Microsoft Visual Studio` folder, the complete installation will not only set the Environment variables but also set the related registry keys and values. A simple copy may break this out... – LoLance Oct 14 '19 at 13:48
  • 3
    If you just want to use VC++ compiler in QT creator instead of developing by VS IDE. You can see [this](https://forum.qt.io/topic/98821/qt-creator-and-visual-c-compilers), another way is to install the free and small [build tools package](https://devblogs.microsoft.com/cppblog/visual-studio-build-tools-now-include-the-vs2017-and-vs2015-msvc-toolsets/) with C++ related workload. Build Tool package [link here](https://visualstudio.microsoft.com/vs/older-downloads/). You should download Build Tools for VS2017. Then there's no need to install VS if you only need VC++ compiler. – LoLance Oct 14 '19 at 14:05
  • @LanceLi-MSFT Thanks, I'm going to try it :-) – Megidd Oct 14 '19 at 14:59
  • @LanceLi-MSFT Your suggestion solved my problem. I downloaded **Microsoft Build Tools 2015 Update 3** from [here](https://visualstudio.microsoft.com/vs/older-downloads/) and Qt Creator auto-detected it. Can you post your comment as answer so that I can close this question by accepting it. Thanks! – Megidd Oct 14 '19 at 16:06

2 Answers2

2

Usually programs on Windows don't work after you just copy the installation folder. So right now there is little you can do to fix it, even if you partially fix, you have no way to know if something else will be broken in the future.

So the recommended solution is to download the installer again and create an offline installer for the next time this happens, you can do that by running the online installer with the following parameters: vs_community.exe --layout c:\vslayout --lang en-US (replace vs_community.exe with the actual name of the online installer file, or rename it), for more options, that might require a smaller download (example if you only need native and don't need .net) check the documentation here for the full set of options you have.

Zlatomir
  • 6,964
  • 3
  • 26
  • 32
  • Up-voted. Thanks. Before downloading, I try a little more to see if I can make Qt Creator detect VS C++ compiler! – Megidd Oct 14 '19 at 08:56
2

To answer the questions in your issue:

Copying the content of C:\Program Files (x86)\Microsoft Visual Studio folder is not a recommended way to install VS.

(The complete installation will not only set the Environment variables but also set the related registry keys and values. A simple copy may break this process)

So we always suggest that users install the VS by vs-installer or offline installation package. (Same like what Zlatomir suggests.)

To your actual requirements:

It seems you're just trying to use VC++ compiler in QT Creator instead of developing QT projects in Visual Studio. So build tools for VS package is enough for you.

See this related issue, if we download Build Tools for VS package with corresponding C++ workload, then we can get the compiler the QT needs. There's no need to install the VS IDE for this situation.

And if we need C++ compiler from VS2017, download the Build Tools for VS2017, if we need C++ compiler from VS2015, download the Build Tools for VS2015 Update3. Link of old version about VS Tools see here.

Update:

From the the link older downloads we can see:

Choose the download button according to which version we need. We can find both VS2017 build tools package and VS2015's there.

enter image description here

LoLance
  • 25,666
  • 1
  • 39
  • 73
  • When I look at [the download page](https://visualstudio.microsoft.com/vs/older-downloads/), there is a link for `Microsoft Build Tools 2015 Update 3` which I downloaded and installed., However for some reason I cannot find `Microsoft Build Tools 2017` link. I wonder whether the 2017 version is available. Thanks =) – Megidd Oct 15 '19 at 05:36
  • 1
    @user3405291 Yes, it is available there. For now the latest vs is VS2019, so all old vs versions are available from the link above, tools for VS2010~2017, I will add a screenshot into my answer and update it later :) – LoLance Oct 15 '19 at 05:41