Ionic and Visual Studio 2017 "Required version of Visual Studio not found."

It should, but unfortunately it doesn’t update the project.
In fact I don’t event see the output from the TS linter and changes in the project (i.e. add text in some pages html) are not reflected in the platform/windows folder…

It looks to me like the Ionic project does not get rebuilt

Can you switch to VS Code? The way I “solved” these problems was ditching Visual Studio and going to Sublime. But you might be more comfortable in VS Code, which is much more respected than Visual Studio around here.

I am using VS code. And I need to open VS2017 just to compile the windows platform.
So what I need is a command to update the windows platform so that I can open it in VS2017 and compile.

So far only this works:

  1. Work on the app in VS Code
  2. Run ionic serve to build the Ionic project
  3. Run ionic cordova prepare windows to update the windows platform
  4. Build the windows platform with VS2017

My question is: why is step 1 required? Shouldn’t ionic cordova prepare build the Ionic project as well?

SOLVED!

For all future readers not able to use Ionic/cordova CLI to build for windows using VS2017 here’s what you’re missing:

You need to set the env variable you see in the picture for Cordova to find VS2017 build tools

4 Likes

I am not 100% sure, in the recent CLI releases a build was added to a lot of steps but I am not sure if ionic cordova prepare was one of them. If it doesn’t output the build step stuff, it doesn’t build…

By the way: Be aware that ionic serve and ionic build and ionic build --prod and ionic cordova build windows do slightly different things - tailored to what is needed in each “environment”.

Awesome!

You can now build on the CLI without Visual Studio 2015 being installed?

What does cordova requirements output now?

This thing here. But everything works!

But I still need to build the binary in VS2017 cause the Cordova-sqlite-storage plugin requires the architecture (i.e. x64) to be specified and ionic cordova build seems to ignore the --archs="x64" attribute.

So you think the right procedure would be the following?

  1. ionic build --prod
  2. ionic cordova prepare windows (EDIT: just found out that this is already called by ionic build)
  3. Open the solution in VS2017 and build from there

This should be the right wat to build a ionic project for windows in Visual Studio, right? Works for me, at least.

Ok, it recognizes the MSBuild Tools but not VS itself. Maybe cordova-windows can fix that in the near future.

Yes, if the pure CLI workflow doesn’t work this looks like a valid one.

Here’s some notes I have while getting my project to build with Visual Studio 2017 (as it was quite a mission)

  1. The cordova build command looks in the registry for the MSBuild path, but since Visual Studio 2017 Microsoft doesn’t write the path in the registry anymore (more on this here)
    As workaround i created in the registry the following key (don’t forget to change the path):
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\15.0]
"MSBuildToolsPath"="C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\MSBuild\\15.0\\Bin\\amd64"
  1. Make sure also install C++ mobile tools, as need the SQL Lite from it

  2. To build it all (including the SQLite), i need to pass the -- --arch=x86 flag, so my build looks like

ionic cordova build windows --prod --release -- --arch=x86 

My only outstanding problem is the images (slash screen and icons) are not being created/copied.

2 Likes