microsoft / vsts-cordova-tasks

Streamline CI setup for your Apache Cordova, PhoneGap, Ionic, or Cordova CLI compatible app using a set of useful pre-defined build steps for VS Team Services or TFS
http://go.microsoft.com/fwlink/?LinkID=691188
Other
25 stars 27 forks source link

CordovaError: Platform ios already added #59

Closed jrmcdona closed 7 years ago

jrmcdona commented 7 years ago

Hi Folks,

I created an SO question yesterday due to a build failure, didn't realize you all had a GIT repo. It is described here.

http://stackoverflow.com/questions/41030755/cordovaerror-platform-ios-already-added

Please note; I have Platforms in my working directory but I do not have Platforms in my source control branch.

Thanks Jordan

MSLaguana commented 7 years ago

I've had a look at this, and I'm a bit confused how it could happen. I believe the error is happening when we execute the line at https://github.com/Microsoft/taco-team-build/blob/master/taco-team-build.js#L227 but that line should only be executed after we've checked for the platform and not found it.

You mentioned that you are running the agent in interactive mode; are you running the agent from within (perhaps multiple folders down) a cordova project?

jrmcdona commented 7 years ago

My repo looks like this. I am building myApp which is a test app to get buiild working. screen shot 2016-12-08 at 2 06 21 pm

jrmcdona commented 7 years ago

Here is my agent, see pic below. Not sure what you mean by running deep in a cordova project. The agent was installed separately in a different folder. The agent was installed in my Documents folder.

Documents/iosagent

The repo is here: Documents/repos/Safetypin/myApp screen shot 2016-12-08 at 3 23 23 pm

MSLaguana commented 7 years ago

It looks like you've uploaded the same picture twice, but I was wondering whether you had run the agent from a folder /some/path/to/a/folder/ where a parent such as /some/path/ was a cordova project with a config.xml and a platforms folder.

If that was the case, then cordova can get confused about the project it is operating on, and that may have caused this kind of issue.

jrmcdona commented 7 years ago

I updated my answer and fixed the picture, but looks like not in time. But if you refresh it may be helpful.

MSLaguana commented 7 years ago

Just to be sure: what folder were you in when you ran ./run.sh? And if you run cordova info in that same location does it print out a bunch of information, or an error stating that the current folder is not a cordova project?

jrmcdona commented 7 years ago

Well maybe this is the issue! I was in my iosagent folder. Do I need to run the /run sh from the "myApp" folder for this to work right?

Jordans-Mac-mini:iosagent jordanmc$ cordova info Error: Current working directory is not a Cordova-based project. Jordans-Mac-mini:iosagent jordanmc$

MSLaguana commented 7 years ago

No, you need to make sure that it does not run from inside there, I just wanted to make sure that you weren't; the error from cordova info is exactly what you want to see there to make sure that when the agent runs cordova commands it must be working from inside your project, not some other one it happened to find.

jrmcdona commented 7 years ago

Here is what i get when I run cordova info from my project:

Jordans-Mac-mini:myApp jordanmc$ cordova info Collecting Data...

Node version: v6.6.0

Cordova version: 6.4.0

Config.xml file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

myApp An Ionic Framework and Cordova project. Your Name Here

Plugins:

cordova-plugin-console,cordova-plugin-device,cordova-plugin-splashscreen,cordova-plugin-statusbar,cordova-plugin-vs-taco-support,cordova-plugin-whitelist,ionic-plugin-keyboard

iOS platform:

Xcode 8.0 Build version 8A218a

MSLaguana commented 7 years ago

Did you manually add cordova-plugin-vs-taco-support to your project? If not, that looks like you are pointing at the project that is operated on by VSTS, and it has the iOS platform installed (which would cause the error you're seeing).

jrmcdona commented 7 years ago

No I didn't add anything to myApp project. The only thing I did on this project was run command "ionic start myApp tabs" just to get a blank app to get the build working.

But yes, myApp is what is connected to VSTS/GIT and myApp is my local working area and I push it to GIT.

When I was installing the ios agent it asked me for a "Work folder" . This prompt was not in documentation either. I supplied /Documents/repos/myApp to this Work folder. prompt. The default was "_work" but I added my working folder path instead, but I am not sure what this actually is doing and wasn't documented.

It could/should have been in the Download and Configure section of this doc: https://www.visualstudio.com/en-us/docs/build/admin/agents/v2-osx

Could that be an issue?

MSLaguana commented 7 years ago

I believe that is indeed your issue: The work folder is intended to be a folder that the VSTS agent can own and modify freely, so it should be an empty folder initially. Because you had pointed it at your local app folder, it was trying to modify that and confused itself.

Try reconfiguring the app and specifying a fresh folder for the Work folder, and see if that resolves the issue for you. I'll see if I can get the docs updated.

jrmcdona commented 7 years ago

Hi, updated things. So this why I changed "_work" to my own working folder to begin with. Here is the error. Thanks for helping me through this.

Removing Xcconfig update hook { CordovaError: Current working directory is not a Cordova-based project. at Object.cdProjectRoot (/Users/jordanmc/.taco_home/node_modules/cordova/6.4.0/node_modules/cordova-lib/src/cordova/util.js:151:15) at /Users/jordanmc/.taco_home/node_modules/cordova/6.4.0/node_modules/cordova-lib/src/cordova/plugin.js:48:40 at _fulfilled (/Users/jordanmc/.taco_home/node_modules/cordova/6.4.0/node_modules/q/q.js:787:54) at self.promiseDispatch.done (/Users/jordanmc/.taco_home/node_modules/cordova/6.4.0/node_modules/q/q.js:816:30) at Promise.promise.promiseDispatch (/Users/jordanmc/.taco_home/node_modules/cordova/6.4.0/node_modules/q/q.js:749:13) at /Users/jordanmc/.taco_home/node_modules/cordova/6.4.0/node_modules/q/q.js:810:14 at flush (/Users/jordanmc/.taco_home/node_modules/cordova/6.4.0/node_modules/q/q.js:108:17) at _combinedTickCallback (internal/process/next_tick.js:67:7) at process._tickCallback (internal/process/next_tick.js:98:9) name: 'CordovaError', message: 'Current working directory is not a Cordova-based project.', code: 0, context: undefined } Task failed

jrmcdona commented 7 years ago

Hi, Any other thoughts?

Thanks