What about a paladin using Detect Evil, then? If he gets a result, that is almost certainly an enemy, as a paladins detect evil is almost the same as detect enemy?
My question is a bit silly, but also kind of fun theoretically. Its about semantics, really.
My point is that the result doesn't matter. Only the caster's perceptions at casting time matter. Casting time is when the action is taken; therefore,
only at casting time can the action be labelled an "attack."
If the Paladin uses
Detect Evil and pings a critter that he didn't know in advance was Evil, as Evil, then he knows that said critter might be an enemy (and please note: simply having an Evil aura does
not make the critter an automatic enemy of the Paladin except in the most knee-jerk unthinking-reflexive-alignment worlds- a majority of GMs would require more than simple detection of Evil to justify the Paladin attacking the critter without taking a hit against his/her Code of Conduct) and
then and only then will further actions taken against said critter be an "attack" by
Invisibility.
Because concentrating on an active effect is itself an action, there is a gray area wherein a GM might say that a caster
continuing to use a Detection effect upon critters he/she perceives to be hostile
after something the spell detected causes the caster to label them as "enemies," is itself an "attack." In such a case, then a caster who concentrates to maintain the effect would lose
Invisibility. But causing the caster to lose it at casting time clearly goes against the RAW, and the evident intent of the rules.